There are three progressively-deeper methods of installing your node modules, all useful in their own way:
- npm link sets up symlinks to your commands
They will point directly to your code, which you can dynamically change to see the result. This is best for early development. - npm install -g of a package with dependent modules listed on the local drive
This will use the locally installed version of the dependent module that was also installed with [npm install -g]. Format:
"dependencies": {
"rad-scripts": "file:///home/m/development/thedigitalage/rad-scripts"
},
- npm install -g of a package with officially published dependent modules
This will use the latest publicly available version of the dependent module. In this example, the latest version above 1.0.3 will be used. Format:
"dependencies": {
"rad-scripts": "^1.0.3"
},
It is so easy to publish your own node modules. I glided right through these and now have a published module of reusable scripts.
Here’s a quick summary of the lifecycle of publishing your module:
npm install -g
# you can now test this module in another module if you use a [file:] dependency in the other module
# keep doing this until you are happy with local install
# when ready...
# update version in package.json
git commit -a -m "1.0.5"
git tag 1.0.5
git push && git push --tags # NOTE: bitpost has a git hook to push changes all the way up to github
npm publish