Building and Using NPM Packages Locally
Sometimes it is valuable to alter a package locally and use those changes as a dependency of another project. Once you have amde appropriate changes on your machine.
- Build the project. Conventially with a
"script"
field in package.json, usenpm run build
- Go to the parent directory of dist/ (or wherever the compiled output is)
- Issue
npm pack
. This will create a .tgz compressed file with your custom package. - Copy the .tgz file into the root of the project you wish to use it in.
- In package.json replace the version number with
"<package_name>": "file:<packed-file>.tgz"
. - Issue
npm install
with the new package.json
The custom package will now be in your node_modules/.
ADDITIONAL RESOURCES