Using NVM

Use NVM to install NPM, so you can switch Node versions easily. Eventually you’ll need this — so do it now.

Using Mac installer

Install NodeJS by downloading the Mac installer.

Show Node version

node -v


Set up a brand new package.json file:

npm init

Install packages

Find packages on NPM JS.

Install all packages listed in package.json:

npm install

Install package in project (and save to package.json):

npm install --save-dev package-name

Install package globally (should only have to do this once):

sudo npm install -g package-name

Update packages

Check for outdated packages:

npm outdated

Update all packages in package.json:

npm update

# Make sure NPM cache is not holding old versions of packages
npm cache clean


Remove packages

Uninstall module locally (and remove from package.json):

npm uninstall package-name --save-dev

Remove packages not in package.json from /node_modules:

npm prune


When all packages are updated they might be incompatible, and require code changes.

Often enough the local files are just corrupt. Delete the entire node_modules folder, re-install, update, and clean cache.

rm -rf node_modules
npm install
npm update
npm cache clean

If something is still broken, and you can narrow it down to a specific package try uninstalling and re-installing it:

npm uninstall the-package-name
npm install the-package-name