Last modified on 18 Oct 2020.

Install NodeJS & NPM

Install NodeJS and NPM.

Update to latest version?

# npm
npm cache clean -f # clear the cache first
sudo npm install -g npm
# node
sudo npm install -g n
sudo n stable
# refresh the shell
source ~/.zshrc # if using zsh
source ~/.bashrc # is using bash

Check version?

npm -v
node -v

Install package

👉 Official documentation.

npm install package_name # if it's in package.json, the indicated version will be installed
                         # otherwise, the newsest version will be installed
npm install --global package_name # global package
# install all package in package.json
npm install
# install + save to package.json
npm install --save package_name # save to package.json
npm install --save-dev package_name # save to package.json, in devDependencies
npm install --no-save package_name # don't save
# install with version
npm install [email protected]
# list all installed packages (current project only)
ls node_modules
# Check current version of a package
npm -v package_name


  • i: install
  • -D: --save-dev (devDependencies)
  • -P: --save-prod (default), --save
  • -g: --global
  • -f: --force

Remove package

npm uninstall package