Test npm package locally

Girish
Oct 14, 2022

--

npm pack

The pack command creates a .tgz file exactly the way it would if you were going to publish the package to npm. It pulls the name and version from package.json, resulting in a file like package-name-0.0.0.tgz. This can be copied, uploaded, or sent to a coworker. It's exactly the file that would be uploaded to npm if you published it.

npm pack

Once you have the file, you can install it. npm install

$ npm pack
$ cp package-name-0.0.0.tgz ~
$ npm install ~/package-name-0.0.0.tgz

--

--

Girish
Girish

No responses yet