{"id":20617819,"url":"https://github.com/cyclonedx/cyclonedx-node-npm","last_synced_at":"2025-05-15T12:03:41.581Z","repository":{"id":48724485,"uuid":"517006554","full_name":"CycloneDX/cyclonedx-node-npm","owner":"CycloneDX","description":"Create CycloneDX Software Bill of Materials (SBOM) from Node.js NPM projects. ","archived":false,"fork":false,"pushed_at":"2025-05-12T11:52:25.000Z","size":25454,"stargazers_count":87,"open_issues_count":18,"forks_count":23,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-15T12:03:30.203Z","etag":null,"topics":["bill-of-materials","bom","cyclonedx","dependency-graph","hacktoberfest","node","nodejs","npm","owasp","sbom","sbom-generator","sbom-tool","software-bill-of-materials"],"latest_commit_sha":null,"homepage":"https://cyclonedx.org/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CycloneDX.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://owasp.org/donate/?reponame=www-project-cyclonedx\u0026title=OWASP+CycloneDX"]}},"created_at":"2022-07-23T08:53:52.000Z","updated_at":"2025-05-13T18:28:02.000Z","dependencies_parsed_at":"2023-09-29T07:53:02.368Z","dependency_job_id":"2f25ddf4-5518-426a-b939-0281556bdded","html_url":"https://github.com/CycloneDX/cyclonedx-node-npm","commit_stats":{"total_commits":864,"total_committers":9,"mean_commits":96.0,"dds":0.3402777777777778,"last_synced_commit":"40b51e655ee1e50c1aa129b1c00c52997055603f"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CycloneDX%2Fcyclonedx-node-npm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CycloneDX%2Fcyclonedx-node-npm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CycloneDX%2Fcyclonedx-node-npm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CycloneDX%2Fcyclonedx-node-npm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CycloneDX","download_url":"https://codeload.github.com/CycloneDX/cyclonedx-node-npm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254337612,"owners_count":22054253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bill-of-materials","bom","cyclonedx","dependency-graph","hacktoberfest","node","nodejs","npm","owasp","sbom","sbom-generator","sbom-tool","software-bill-of-materials"],"created_at":"2024-11-16T12:06:06.506Z","updated_at":"2025-05-15T12:03:41.550Z","avatar_url":"https://github.com/CycloneDX.png","language":"JavaScript","funding_links":["https://owasp.org/donate/?reponame=www-project-cyclonedx\u0026title=OWASP+CycloneDX"],"categories":[],"sub_categories":[],"readme":"# CycloneDX SBOM for _npm_\n\n[![shield_npm-version]][link_npm]\n[![shield_gh-workflow-test]][link_gh-workflow-test]\n[![shield_coverage]][link_codacy]\n[![shield_ossf-best-practices]][link_ossf-best-practices]\n[![shield_license]][license_file]  \n[![shield_website]][link_website]\n[![shield_slack]][link_slack]\n[![shield_groups]][link_discussion]\n[![shield_twitter-follow]][link_twitter]\n\n----\n\nCreate [CycloneDX] Software Bill of Materials (SBOM) from _[npm]_ projects.  \nThis is probably the most accurate, complete SBOM generator for npm-based projects.\n\nBased on [OWASP Software Component Verification Standard for Software Bill of Materials](https://scvs.owasp.org/scvs/v2-software-bill-of-materials/)'s\ncriteria, this tool is capable of producing SBOM documents almost passing Level-2 (only signing needs to be done externally).\n\nThe resulting SBOM documents follow [official specifications and standards](https://github.com/CycloneDX/specification), \nand might have properties following [`cdx:npm` Namespace Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy/blob/main/cdx/npm.md)\n.\n\n## Requirements\n\n* `node \u003e= 20.18.0`\n* `npm \u003e= 9`\n\nHowever, there are older versions of this tool that support\n* Node.js v14 or later\n* NPM v6 or later\n\n## Installation\n\nThere are multiple methods for installing this tool:\n\n* As a global tool ala `npm`:\n\n  ```shell\n  npm install --global @cyclonedx/cyclonedx-npm\n  ```\n\n* As a global tool ala `npx`:\n\n  ```shell\n  npx --package @cyclonedx/cyclonedx-npm --call exit\n  ```\n\n* As a development dependency of the current project:\n\n  ```shell\n  npm install --save-dev @cyclonedx/cyclonedx-npm\n  ```\n\n## Usage\n\nDepending on the installation method, the following describes the proper usage:\n\n* If installed as a global tool ala `npm`:\n\n  ```shell\n  cyclonedx-npm --help\n  ```\n\n* If installed as a global tool ala `npx`:  \n  — or —  \n  If installed as a development dependency of the current projects:\n\n  ```shell\n  npx @cyclonedx/cyclonedx-npm --help\n  ```\n\nThe help page:\n\n```text\nUsage: cyclonedx-npm [options] [--] [\u003cpackage-manifest\u003e]\n\nCreate CycloneDX Software Bill of Materials (SBOM) from Node.js NPM projects.\n\nArguments:\n  \u003cpackage-manifest\u003e              Path to project's manifest file.\n                                  (default: \"package.json\" file in current working directory)\n\nOptions:\n  --ignore-npm-errors             Whether to ignore errors of NPM.\n                                  This might be used, if \"npm install\" was run with \"--force\" or \"--legacy-peer-deps\".\n                                  (default: false)\n  --package-lock-only             Whether to only use the lock file, ignoring \"node_modules\".\n                                  This means the output will be based only on the few details in and the tree described by the \"npm-shrinkwrap.json\" or \"package-lock.json\", rather than the contents of \"node_modules\" directory.\n                                  (default: false)\n  --omit \u003ctype...\u003e                Dependency types to omit from the installation tree.\n                                  (can be set multiple times)\n                                  (choices: \"dev\", \"optional\", \"peer\", default: \"dev\" if the NODE_ENV environment variable is set to \"production\", otherwise empty)\n  -w, --workspace \u003cworkspace...\u003e  Only include dependencies for specific workspaces.\n                                  (can be set multiple times)\n                                  This feature is experimental.\n                                  (default: empty)\n  --no-workspaces                 Do not include dependencies for workspaces.\n                                  Default behaviour is to include dependencies for all configured workspaces.\n                                  This cannot be used if workspaces have been explicitly defined using `--workspace`.\n                                  This feature is experimental.\n  --include-workspace-root        Include workspace root dependencies along with explicitly defined workspaces' dependencies. This can only be used if you have explicitly defined workspaces using `--workspace`.\n                                  Default behaviour is to not include the workspace root when workspaces are explicitly defined using `--workspace`.\n                                  This feature is experimental.\n  --no-include-workspace-root     Do not include workspace root dependencies. This only has an effect if you have one or more workspaces configured in your project.\n                                  This is useful if you want to include all dependencies for all workspaces without explicitly defining them with `--workspace` (default behaviour) but you do not want the workspace root dependencies included.\n                                  This feature is experimental.\n  --gather-license-texts          Search for license files in components and include them as license evidence.\n                                  This feature is experimental.\n                                  (default: false)\n  --flatten-components            Whether to flatten the components.\n                                  This means the actual nesting of node packages is not represented in the SBOM result.\n                                  (default: false)\n  --short-PURLs                   Omit all qualifiers from PackageURLs.\n                                  This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings.\n                                  (default: false)\n  --sv, --spec-version \u003cversion\u003e  Which version of CycloneDX spec to use.\n                                  (choices: \"1.2\", \"1.3\", \"1.4\", \"1.5\", \"1.6\", default: \"1.6\")\n  --output-reproducible           Whether to go the extra mile and make the output reproducible.\n                                  This requires more resources, and might result in loss of time- and random-based-values.\n                                  (env: BOM_REPRODUCIBLE)\n  --of, --output-format \u003cformat\u003e  Which output format to use.\n                                  (choices: \"JSON\", \"XML\", default: \"JSON\")\n  -o, --output-file \u003cfile\u003e        Path to the output file.\n                                  Set to \"-\" to write to STDOUT.\n                                  (default: write to STDOUT)\n  --validate                      Validate resulting BOM before outputting.\n                                  Validation is skipped, if requirements not met. See the README.\n  --no-validate                   Disable validation of resulting BOM.\n  --mc-type \u003ctype\u003e                Type of the main component.\n                                  (choices: \"application\", \"firmware\", \"library\", default: \"application\")\n  -v, --verbose                   Increase the verbosity of messages.\n                                  Use multiple times to increase the verbosity even more.\n  -V, --version                   output the version number\n  -h, --help                      display help for command\n```\n\n## Demo\n\nFor a demo of _cyclonedx-npm_ see the [demo projects][demo_readme].\n\n## How it works\n\nThis tool utilizes _[npm]_ to collect evidences of installed packages/modules.\nRead more in the [dedicated docs](https://github.com/CycloneDX/cyclonedx-node-npm/tree/main/docs/how.md).\n\nThe appropriate _npm_ executable is detected automatically, yet can be overridden with the environment variable `npm_execpath`.  \nAutodetect: If called from `npm`/`npx` context, then the current _npm_ executable is utilized, otherwise it is managed by SHELL and PATH.\n\nThis tool does not do artificial deduplication.\nTherefore, if a component is installed multiple times, it appears multiple times in the SBOM result.\nRead more on the topic in the [dedicated docs \"Component Deduplication\"](https://github.com/CycloneDX/cyclonedx-node-npm/tree/main/docs/component_deduplication.md).\n\n## Internals\n\nThis tool utilizes the [CycloneDX library][cyclonedx-library] to generate the actual data structures, and serialize and validate them.  \nValidation requires [transitive optional dependencies](https://github.com/CycloneDX/cyclonedx-javascript-library/blob/main/README.md#optional-dependencies).\n\nThis tool does **not** expose any additional _public_ API or classes - all code is intended to be internal and might change without any notice during version upgrades.\nHowever, the CLI is stable - you may call it programmatically like:\n```javascript\nconst { execFileSync } = require('child_process')\nconst { constants: { MAX_LENGTH: BUFFER_MAX_LENGTH } } = require('buffer')\nconst sbom = JSON.parse(execFileSync(process.execPath, [\n    '../path/to/this/package/bin/cyclonedx-npm-cli.js',\n    '--output-format', 'JSON',\n    '--output-file', '-'\n    // additional CLI args\n], { stdio: ['ignore', 'pipe', 'ignore'], encoding: 'buffer', maxBuffer: BUFFER_MAX_LENGTH }))\n```\n## Contributing\n\nFeel free to open issues, bugreports or pull requests.  \nSee the [CONTRIBUTING][contributing_file] file for details.\n\n## License\n\nPermission to modify and redistribute is granted under the terms of the Apache 2.0 license.  \nSee the [LICENSE][license_file] file for the full license.\n\n[license_file]: https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/LICENSE\n[contributing_file]: https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/CONTRIBUTING.md\n[demo_readme]: https://github.com/CycloneDX/cyclonedx-node-npm/blob/main/demo/README.md\n\n[CycloneDX]: https://cyclonedx.org/\n[npm]: http://www.npmjs.com/\n[cyclonedx-library]: https://www.npmjs.com/package/@cyclonedx/cyclonedx-library\n\n[shield_gh-workflow-test]: https://img.shields.io/github/actions/workflow/status/CycloneDX/cyclonedx-node-npm/nodejs.yml?branch=main\u0026logo=GitHub\u0026logoColor=white \"tests\"\n[shield_ossf-best-practices]: https://img.shields.io/cii/level/6614?label=OpenSSF%20best%20practices \"OpenSSF best practices\"\n[shield_coverage]: https://img.shields.io/codacy/coverage/16b034e5463543008e1cc0e2a3ed7005?logo=Codacy\u0026logoColor=white \"test coverage\"\n[shield_npm-version]: https://img.shields.io/npm/v/%40cyclonedx%2fcyclonedx-npm/latest?label=npm\u0026logo=npm\u0026logoColor=white \"npm\"\n[shield_license]: https://img.shields.io/github/license/CycloneDX/cyclonedx-node-npm?logo=open%20source%20initiative\u0026logoColor=white \"license\"\n[shield_website]: https://img.shields.io/badge/https://-cyclonedx.org-blue.svg \"homepage\"\n[shield_slack]: https://img.shields.io/badge/slack-join-blue?logo=Slack\u0026logoColor=white \"slack join\"\n[shield_groups]: https://img.shields.io/badge/discussion-groups.io-blue.svg \"groups discussion\"\n[shield_twitter-follow]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter\u0026logoColor=white \"twitter follow\"\n\n[link_website]: https://cyclonedx.org/\n[link_gh-workflow-test]: https://github.com/CycloneDX/cyclonedx-node-npm/actions/workflows/nodejs.yml?query=branch%3Amain\n[link_codacy]: https://app.codacy.com/gh/CycloneDX/cyclonedx-node-npm/dashboard\n[link_ossf-best-practices]: https://www.bestpractices.dev/projects/6614\n[link_npm]: https://www.npmjs.com/package/@cyclonedx/cyclonedx-npm\n[link_slack]: https://cyclonedx.org/slack/invite\n[link_discussion]: https://groups.io/g/CycloneDX\n[link_twitter]: https://twitter.com/CycloneDX_Spec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyclonedx%2Fcyclonedx-node-npm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyclonedx%2Fcyclonedx-node-npm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyclonedx%2Fcyclonedx-node-npm/lists"}