Tools
npm Cheat Sheet — Command Reference
Everyday npm commands for managing dependencies and running project scripts.
Advertisement
Installing
npm installInstall everything in package.jsonnpm install pkgAdd a dependencynpm install -D pkgAdd a dev dependencynpm install -g pkgInstall globallynpm install [email protected]Install a specific versionnpm ciClean install from the lockfile (for CI)npm uninstall pkgRemove a packageScripts
npm run <script>Run a script from package.jsonnpm startShorthand for the start scriptnpm testShorthand for the test scriptnpm runList all available scriptsnpx <pkg>Run a package without installing itInfo & updates
npm list --depth=0List top-level installed packagesnpm outdatedShow packages with newer versionsnpm updateUpdate within the allowed semver rangenpm view pkg versionsList all published versionsnpm auditCheck for known vulnerabilitiesnpm audit fixAuto-fix vulnerabilities where possibleVersioning & publishing
npm version patchBump the patch version and tag itnpm version minor|majorBump the minor or major versionnpm publishPublish the package to the registrynpm publish --access publicPublish a scoped package publiclySemver ranges
^1.2.3Allow minor and patch updates (1.x.x)~1.2.3Allow patch updates only (1.2.x)1.2.3Exactly this version*Any version (avoid)