Skip to content

This is a simple tool to collect all production node modules used in a project

Notifications You must be signed in to change notification settings

beyondkmp/NodeModuleCollector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

import { getNodeModules } from 'node-module-collector'
const result = await getNodeModules(rootDir)

result is node modules array, like:

[
  {
    "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

  • npm
  • pnpm
  • pnpm with hosited
  • yarn1
  • yarn berry(with node-modules)

About

This is a simple tool to collect all production node modules used in a project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published