Check Runtimes
node -v
show node.js version / check if node / npm is installed
npm -v
show npm version
**Be in the same directory as package.json from here on**
npm init
initialise package.json
npm install
install and/or update all packages, dependant on package.json and semantic versioning (below)
npm install <pkg> | <pkg>@latest
install (or update) package | install latest
npm install --save-dev | -g | <pkg>@1.2.3
install package as dev dependancy | globally (c:\) | specific version
npx -p @packagename packagecommand
temporarily install package, run package command (ie create-react-app)
npm run <scripttag>
run script defined in package.json\scripts\<scripttag>
npm start
run "start" scripts defined in package.json
npm audit
audit packages (for vulnerabilities etc)
npm audit fix | --force
(same as npm install) | run npm install *@latest on everything
npm outdated
check for outdated packages
npm uninstall <pkg>
unistall named package
npm cache verify
verify npm cache
npm cache clean --force
clear npm cache
Terminology
package.json
dependancies
installed for dev env and prod
devDependancies
installed only for dev env
Semantic versioning
1.2.3
(Major.minor.patch)
(potentially breaking change, non breaking change, patch)
^1.2.3 update minor & patches
~1.2.3 update patches
1.2.3 install only this version