npm

Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser.

Getting Started

List everything you have installed in the current directory

npm ls

Search the registry for packages matching terms

npm search [search terms]

Install a package

npm install[<name> [<name> ...]] [--save|--save-dev|--save-optional]

This command installs a package, or packages, and any packages that
it depends on in the current directory. If the package has a shrinkwrap
file, the installation of dependencies will be driven by that.

If no package.json exists, these options are ignored. If it exists, they'll
update them if they are already there.

--save: Package will appear in your depedencies.

--save-dev: Package will appear in your devDependencies.

--save-optional: Package will appear in your optionalDependencies.

--global: Package will be installed globally (if you want to use it as a command line tool for example)