Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beyondkmp/nodemodulecollector
This is a simple tool to collect all production node modules used in a project
https://github.com/beyondkmp/nodemodulecollector
asar electron-builder npm pnpm yarn
Last synced: 20 days ago
JSON representation
This is a simple tool to collect all production node modules used in a project
- Host: GitHub
- URL: https://github.com/beyondkmp/nodemodulecollector
- Owner: beyondkmp
- Created: 2024-09-27T01:26:08.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-05T03:00:51.000Z (about 1 month ago)
- Last Synced: 2024-10-13T00:04:49.571Z (about 1 month ago)
- Topics: asar, electron-builder, npm, pnpm, yarn
- Language: TypeScript
- Homepage:
- Size: 2.56 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-module-collector
This is a simple tool to collect all production node modules used in a project. It supports npm, yarn1, pnpm and yarn berry(with node-modules).
It is useful to collect all production node modules for a electron project, so that you can easily to package them into electron asar.
## Design
1. Get node modules tree from "npm list"(npm & yarn) or "pnpm list"
2. Transform the tree to dependency graph
3. Transform the graph to hoisted tree
4. Hoisted tree to node modules array## Usage
```shell
import { getNodeModules } from 'node-module-collector'
const result = await getNodeModules(rootDir)
```result is node modules array, like:
```json
[
{
"name": "foo",
"version": "1.0.0",
"dir": "/path/fixtures/yarn-workspace-demo/node_modules/foo",
"dependencies": [
{
"name": "ms",
"version": "2.0.0",
"dir": "/path/fixtures/yarn-workspace-demo/node_modules/ms"
}
]
},
{
"name": "ms",
"version": "2.1.1",
"dir": "/path/fixtures/yarn-workspace-demo/packages/test-app/node_modules/ms"
}
]
```## Support
- [x] npm
- [x] pnpm
- [x] pnpm with hosited
- [x] yarn1
- [x] yarn berry(with node-modules)