The registry stores the packages. Modules are hosting in a variety of places but everything is in the registry because you don’t want to have to just rely on GitHub. Npm exists to make sure js, node, and everything else are working well together. The registry also enables discovery. A registry is faster than having to do a
git clone or something similar. Git is for developing and collaborating but npm is for distributing.
This section was sort of a greatest hits of cool stuff about npm you should probably know.
So first you want to make sure you’re always updating your npm by doing
npm install -g npm. Currently you can also use a
scope command which let you publish your packages under your own name. You can also group packages together and have private packages. The
npm init file controls how npm runs, you can add defaults there, change it, etc. There’s also
promzard. You can do
npm install with
- -save to add a package to your dependencies. You can also do
- -save-dev to only in stall it to your dev dependencies. Bundled dependencies makes downloading packages faster. Additionally, when you
npm install npm goes to the server, gets a list of all the versions, and puts one of those persons on your computer. It also puts the version into the local cache of your computer. Because of this, you can also do an install offline.
There are run scripts, mainly
npm restart, and
npm test. You can use these scripts to get dev dependencies for specific things like mocha.
Now on to
.npmignore. It works like
.gitignore and automatically excludes things from your package. You also need to remember to change your semantic versioning number when you change you package. You can do this right from the command line by doing something like
npm version patch -m “bump to version %s.” There’s something called
shrink wrap and then finally npm organizations. There you can give permissions to specific teams by checking out
npm team and
npm access. In team, you can
destroy, etc. and in access you can
You can work on multiple packages by linking them user
npm link and you can publish with distinct tags. You can also
npm unpiblish <pkg>@<version>, but you actually never want to do this. First, you can’t unpublish after 24 hours. Second, once you publish, it’s out there in the world and unpublishing doesn’t get that data back.
In order to keep packages up to date you can check out
npm outdated and do
npm update, There are package config variables that you can change with the
npm config set command. There are also lifecycle hooks like
start, etc, and each of these has a
pre command and a
post command to allow for work flow automation and validity checks. You can put default config options in your
.npmrc file. Install the Wombat cli which gives you the latest experimental stuff and allows you to manage web hooks by doing
npm install wombat -g. And you can use web hooks to automatically deploy.
Wow. That was a lot of commands. So now for