{"id":26126192,"url":"https://github.com/discoveryjs/node-modules","last_synced_at":"2025-09-14T15:05:46.707Z","repository":{"id":35103254,"uuid":"206983806","full_name":"discoveryjs/node-modules","owner":"discoveryjs","description":"An utility for scan and analyze packages in `node_modules`","archived":false,"fork":false,"pushed_at":"2022-02-12T13:29:24.000Z","size":33,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T07:14:17.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/discoveryjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-07T15:01:08.000Z","updated_at":"2024-07-05T23:39:45.000Z","dependencies_parsed_at":"2022-08-08T05:01:14.262Z","dependency_job_id":null,"html_url":"https://github.com/discoveryjs/node-modules","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/discoveryjs/node-modules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fnode-modules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fnode-modules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fnode-modules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fnode-modules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discoveryjs","download_url":"https://codeload.github.com/discoveryjs/node-modules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discoveryjs%2Fnode-modules/sbom","scorecard":{"id":344660,"data":{"date":"2025-08-11","repo":{"name":"github.com/discoveryjs/node-modules","commit":"d636055c8f00ffb7418ec722096f4d461e33cb8f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T06:45:48.051Z","repository_id":35103254,"created_at":"2025-08-18T06:45:48.051Z","updated_at":"2025-08-18T06:45:48.051Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275121427,"owners_count":25409034,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-10T17:28:01.625Z","updated_at":"2025-09-14T15:05:46.682Z","avatar_url":"https://github.com/discoveryjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @discoveryjs/node-modules\n\n[![NPM version](https://img.shields.io/npm/v/@discoveryjs/node-modules.svg)](https://www.npmjs.com/package/@discoveryjs/node-modules)\n[![Twitter](https://img.shields.io/badge/Twitter-@js_discovery-blue.svg)](https://twitter.com/js_discovery)\n\nAn utility for scan and analyze packages in `node_modules`. It uses file system scan to determine which package physical instances are exactly installed in `node_modules`.\n\nIs a part of [Discovery.js](https://github.com/discoveryjs) projects.\n\n\u003c!-- TOC depthFrom:2 --\u003e\n\n- [How to use](#how-to-use)\n- [API](#api)\n    - [fetchNodeModules(basedir): Promise.\u003cpackages: Array\u003e](#fetchnodemodulesbasedir-promisepackages-array)\n    - [fetchNodeModules.analyzer(file, content, context)](#fetchnodemodulesanalyzerfile-content-context)\n- [Examples](#examples)\n- [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n## How to use\n\nInstall:\n\n```\nnpm install @discoveryjs/node-modules\n```\n\nUse:\n\n```js\nconst fetchNodeModules = require('@discoveryjs/node-modules');\n\nfetchNodeModules('absolute/path/to/project').then(packages =\u003e {\n    // do something with found packages\n});\n```\n\nSee [examples](#examples) below.\n\n## API\n\n### fetchNodeModules(basedir): Promise.\u003cpackages: Array\u003e\n\nMain function to fetch a package list for a specified `basedir`. The method check `basedir` for `node_modules` and `package.json` to retrieve a package list. When `basedir` is not specified `process.cwd()` is using. Root `package.json` is optional and used to determine which packages are using for development purposes only.\n\nA list of packages contains each physical instance of packages. That is, if a package has several copies of itself (e.g. due to various versions) all of them will be in the list. Each entry has following properties:\n- `name` – value of `name` field in `package.json`\n- `version` – value of `version` field in `package.json`; can be `null` for root `package.json`\n- `dev` – boolean value, which `true` when a package is using for dev purposes only\n- `path` – relative to `basedir` path to a package. It can be used as an unique identifier of a package instance (and `deps.resolved` use the same values for a reference)\n- `entry` - relative to `path` path to an entry point module. It can be `null` when entry is not resolved\n- `deps` - list of entries from `dependencies`, `peerDependencies` and `optionalDependencies` sections of `package.json`. `devDependencies` are included for root `package.json` only. Each entry has following properties:\n    - `type` – one of `prod`, `peer`, `optional` or `dev`\n    - `name` - a key from a dependency section\n    - `version` - a value from a dependency section\n    - `resolved` - resolved path to a package. It can be used to find a physical instance of package it refers to. It may contain `null`, if no physical instance of package is not found (Note: that's a missed dependency for `prod`, `peer` and `dev` dependencies, but not a problem for `optional`).\n- `packageJson` - content of a `package.json` parsed with `JSON.parse()`\n\n### fetchNodeModules.analyzer(file, content, context)\n\nAnalyzer to use with [@discoveryjs/scan-fs](https://github.com/discoveryjs/scan-fs):\n\n```js\nconst scanFs = require('@discoveryjs/scan-fs');\nconst nodeModules = require('@discoveryjs/node-modules');\n\nscanFs({\n    ...\n    rules: [\n        ...\n        {\n            test: /\\/package\\.json$/,\n            extract: nodeModules.analyzer\n        }\n    ]\n});\n```\n\n## Examples\n\n```js\nconst fetchNodeModules = require('@discoveryjs/node-modules');\n\nfetchNodeModules(__dirname).then(modules =\u003e {\n    const groupByName = modules.reduce(\n        (map, entry) =\u003e map.set(entry.name, (map.get(entry.name) || []).concat(entry)),\n        new Map()\n    );\n\n    // find packages with more than one physical instance\n    // and sort by entry count from top to bottom\n    const duplicates = [...groupByName]\n        .filter(([, entries]) =\u003e entries.length \u003e 1)\n        .sort(([, a], [, b]) =\u003e b.length - a.length);\n    \n    // output findings\n    duplicates.forEach(([name, entries]) =\u003e {\n        console.log(`${name} (${entries.length} entries)`);\n        entries.forEach(({ path, version }) =\u003e console.log(`  ${path} ${version}`));\n    });\n});\n```\n\nThe same example but using [jora](https://github.com/discoveryjs/jora):\n\n```js\nconst fetchNodeModules = require('@discoveryjs/node-modules');\nconst jora = require('jora');\n\nfetchNodeModules(__dirname).then(modules =\u003e {\n    const duplicates = jora(`\n        group(\u003cname\u003e).({ name: key, entries: value })\n        .[entries.size() \u003e 1]\n        .sort(\u003centries.size()\u003e)\n        .reverse()\n    `)(modules);\n    \n    // output findings\n    duplicates.forEach(({ name, entries }) =\u003e {\n        console.log(`${name} (${entries.length} entries)`);\n        entries.forEach(({ path, version }) =\u003e console.log(`  ${path} ${version}`));\n    });\n});\n```\n\nExample of output in both cases:\n\n```\nansi-regex (2 entries)\n  node_modules/ansi-regex 3.0.0\n  node_modules/strip-ansi/node_modules/ansi-regex 4.1.0\nresolve-from (2 entries)\n  node_modules/resolve-from 5.0.0\n  node_modules/import-fresh/node_modules/resolve-from 4.0.0\n...\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoveryjs%2Fnode-modules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscoveryjs%2Fnode-modules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscoveryjs%2Fnode-modules/lists"}