Publishing NPM packages

This is a summary post for the great tutorial by coolaj86 found here:

Step 1: Create an npm account

The first thing you will need to do (if you have not already done this) is register an account on npm that you will use to publish your packages under.

It's as simple as going to the signup page and completing the registration form.

Step 2: Sign in locally

Next you will need sign into npm using your account created in (step 1), to do this open a command prompt (or bash) and enter in the following commands:

npm set "Your Name"
npm set ""
npm set ""
npm adduser

Be sure to enter in the last command npm adduser as it starts a wizard which will prompt you for the information you used when creating your account.

Step 3: Initialize your project

Next up you will need to initialize your project using npm init, this creates all the nececary configuration required to publish your package to npm.

cd /path/to/your-project
npm init

npm install -g pakmanager
# this shows you dependencies as you `require`d them
pakmanager deps
# now edit `package.json` and add any deps you forgot about

npm publish ./

Beta and release versions

npm publish ./ --tag beta

If you published a bugfix as v1.0.7 and need to set v1.1.3 back to latest

git checkout v1.0.7
npm publish ./

vgit checkout v1.1.3
npm tag foobar@1.1.3 latest

Step 4: Profit

That's all there is to it

comments powered by Disqus