Npm
(Redirected from NPM)
Jump to navigation
Jump to search
npm is dependency/package manager that comes with Node.js and allows to install packages both globally and locally.
References
Quickstart
# Upgrade npm
sudo npm install -g npm
# Install all dependencies of new project / checked-out branch
# ... this align versions with those in package.json
npm ci
# Install (newer version) of packages referenced in package.json
npm install
# Add a new package
npm install PACKAGE
# Add a new package, as development dependency (eg. test framework)
npm install -D typescript
# Install package globally
# ... usually not recommended since it breaks reproducibility.
# ... better use 'npx'
npm install -g PACKAGE
# Update dependency
npm update PACKAGE
npx
npx is Node.js package runner. It either runs package from local node_modules/ or from a global cache.
Install npx
Using npm, install globally (maybe only reason to install anything globally):
npm install -g npx
Or use Nvm.