Programming · Cheatsheet
NPM Commands Cheatsheet
Package management: install, update, publish, scripts, audit, and configuration
59 commands 9 sections
No entry matches that filter.
-
npm initInitialize package.json interactively -
npm init -yInitialize with defaults (skip prompts) -
npm init @scopeRun a create package (e.g., create-react-app) -
npx create-next-app@latestRun package without installing globally -
npm pkg set name="my-app"Set field in package.json -
npm pkg get versionGet field from package.json
-
npm installInstall all dependencies from package.json -
npm install <pkg>Install and add to dependencies -
npm install <pkg> --save-devInstall as dev dependency -
npm install <pkg>@<version>Install specific version -
npm install <pkg>@latestInstall latest version -
npm install -g <pkg>Install package globally -
npm ciClean install from lock file (CI/CD) -
npm install --legacy-peer-depsIgnore peer dependency conflicts
-
npm uninstall <pkg>Remove a package -
npm updateUpdate all packages to latest allowed -
npm update <pkg>Update specific package -
npm outdatedShow packages needing updates -
npm lsList installed packages (tree view) -
npm ls --depth=0List top-level packages only -
npm ls <pkg>Check where a package is used -
npm dedupeReduce duplication in node_modules -
npm pruneRemove extraneous packages
-
npm run <script>Run a script from package.json -
npm startRun the start script -
npm testRun the test script -
npm run buildRun the build script -
npm run devRun the dev script -
npx <command>Run a package binary without global install -
npm run lint -- --fixPass extra arguments to script
-
npm view <pkg>Show package registry info -
npm view <pkg> versionsList all published versions -
npm search <keyword>Search npm registry -
npm info <pkg> dependenciesShow package dependencies -
npm docs <pkg>Open package documentation -
npm repo <pkg>Open package repository -
npm bugs <pkg>Open package issue tracker
-
npm loginAuthenticate to npm registry -
npm publishPublish package to registry -
npm publish --access publicPublish scoped package as public -
npm version patchBump patch version (1.0.0 → 1.0.1) -
npm version minorBump minor version (1.0.0 → 1.1.0) -
npm version majorBump major version (1.0.0 → 2.0.0) -
npm deprecate <pkg>@<ver> "message"Deprecate a package version -
npm unpublish <pkg>@<ver>Remove a published version
-
npm config listShow current npm configuration -
npm config set registry <url>Set custom registry URL -
npm config get prefixShow global install directory -
npm cache clean --forceClear npm cache -
npm cache verifyVerify cache integrity -
npm root -gShow global node_modules path -
npm doctorRun diagnostics on npm setup
-
npm auditCheck for known vulnerabilities -
npm audit fixAuto-fix vulnerabilities -
npm audit fix --forceFix vulnerabilities (breaking changes allowed) -
npm audit --jsonOutput audit results as JSON -
npm token listList active authentication tokens -
npm whoamiShow currently logged-in user
-
https://docs.npmjs.com/cli/v11/commands/npm CLI v11 reference: installation, scripts, publishing, configuration, and audit commands.