There could be several situations where you want to locally deploy an npm module of your own before publishing it to npmjs.org.
Say you’ve just created one and want to see how it deploys, or you’re fixing bugs and you want to test the module in integration before publishing a new version, or you just want to keep your npm private.
To create a local npm, change directory to where its package.json is.
cd /path/to/package.json
Then run the pack command:
npm pack
This will create, in the same directory, a tarball named after the name of the project + the version specified in the package.json.
This is exactly what is published to npmjs.org! You can now see what’s inside
tar -tf packagename-version.tgz
Or you can install it in your project to test it in integration.
cd path/to/your/project/
npm install ../path/to/your/npm/packagename-version.tgz
As you can see, ‘npm install’ can either be used to fetch an npm on the official repository, or to install a local one.
Note that each time you’ll run npm install, the previous files will be overridden by the new ones, regardless of the version number, which is pretty convenient!
Hope this helps!