Is there a way for `npm pack` to include all dependency packages recursively instead of just the base package? Why does it do that?

Viewed 569

For example in this picture:

enter image description here

npm pack only packages the contents of electron-builder@22.8.1, but I'd like it to package all of the required 14 dependencies and then its children dependencies recursively until I know I could use electron-builder@22.8.1 correctly with a npm install with no troubles.

Is there a way to do this?

Why does npm pack only do the top level instead of all the packages associated with it?

For context, I'm going this way instead of simply npm install electron-builder because I'm packaging these items to be installed in an offline computer.

2 Answers

I made a CLI tool (GitHub, npm) to recursively pack dependencies for offline networks.

basic usage: npm-deep-pack <package_name>

There was already a cool tool named package-bundle (GitHub,npm) but i had some troubles with it.

I use npm-offline-packager for this all the time.

Once you've installed it by running npm i -g npm-offline-packager, just run npo fetch --no-cache --peer <package name>.

Related