Npm: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→npx) |
||
Line 35: | Line 35: | ||
* https://www.freecodecamp.org/news/npm-vs-npx-whats-the-difference/ |
* https://www.freecodecamp.org/news/npm-vs-npx-whats-the-difference/ |
||
=== Install npx === |
|||
Using npm, install globally (maybe only reason to install anything globally): |
|||
npm install -g npx |
|||
Or use [[Node.js|Nvm]]. |
Latest revision as of 12:06, 1 November 2021
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.