NPM is the NodeJS Package Manager. Most users will just use it to install dependent packages via the
npm install command. However, if you want to submit your packages as a developer, there's a bit more to know:
First create an account, by going to https://npmjs.org/signup and signing up. Then:
npm set init.author.name "Your Name" npm set init.author.email "email@example.com" npm set init.author.url "http://coderwall.com/you" npm adduser
That will create an
~/.npmrc file with lines like:
init.author.name = Your Name init.author.email = firstname.lastname@example.org init.author.url = http://coderwall.com/you
Say you've created the
amazing-library package, and you want to make sure that
amazing-application that uses said package actually works, but is a separate repository. Instead of alternately publishing and version-incrementing each of those two multiple times, there's the
npm link command that lets a local folder/repository act like it's the published module.
Go to the
amazing-library folder and run
npm link. That will create symbolic link in your local npm install's list of globally-installed modules to the current folder. Then go to the
amazing-application folder and run
npm link amazing-library. That will create a symbolic link in
node_modules folder to the global module location (which is pointing at the local folder, so bounces to there).
npm publish sends the package information to NPM, so it can be required by other packages.
However, NPM doesn't scan the git repository for updates, so in order for the world to see any updates you make, you need to re-publish the package. The
npm version command makes that slightly easier if you're publishing a git-controlled package by auto-editing the
package.json file and setting a git tag at that location.
npm version patch -m "Squashing bugs 42-44" npm publish