Programming58 entries
NPM Commands
Package management: install, update, publish, scripts, audit, and configuration
1Project Setup
npm init | Initialize package.json interactively |
npm init -y | Initialize with defaults (skip prompts) |
npm init @scope | Run a create package (e.g., create-react-app) |
npx create-next-app@latest | Run package without installing globally |
npm pkg set name="my-app" | Set field in package.json |
npm pkg get version | Get field from package.json |
2Installing Packages
npm install | Install all dependencies from package.json |
npm install <pkg> | Install and add to dependencies |
npm install <pkg> --save-dev | Install as dev dependency |
npm install <pkg>@<version> | Install specific version |
npm install <pkg>@latest | Install latest version |
npm install -g <pkg> | Install package globally |
npm ci | Clean install from lock file (CI/CD) |
npm install --legacy-peer-deps | Ignore peer dependency conflicts |
3Managing Packages
npm uninstall <pkg> | Remove a package |
npm update | Update all packages to latest allowed |
npm update <pkg> | Update specific package |
npm outdated | Show packages needing updates |
npm ls | List installed packages (tree view) |
npm ls --depth=0 | List top-level packages only |
npm ls <pkg> | Check where a package is used |
npm dedupe | Reduce duplication in node_modules |
npm prune | Remove extraneous packages |
4Running Scripts
npm run <script> | Run a script from package.json |
npm start | Run the start script |
npm test | Run the test script |
npm run build | Run the build script |
npm run dev | Run the dev script |
npx <command> | Run a package binary without global install |
npm run lint -- --fix | Pass extra arguments to script |
5Package Info & Search
npm view <pkg> | Show package registry info |
npm view <pkg> versions | List all published versions |
npm search <keyword> | Search npm registry |
npm info <pkg> dependencies | Show package dependencies |
npm docs <pkg> | Open package documentation |
npm repo <pkg> | Open package repository |
npm bugs <pkg> | Open package issue tracker |
6Publishing & Versioning
npm login | Authenticate to npm registry |
npm publish | Publish package to registry |
npm publish --access public | Publish scoped package as public |
npm version patch | Bump patch version (1.0.0 → 1.0.1) |
npm version minor | Bump minor version (1.0.0 → 1.1.0) |
npm version major | Bump 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 |
7Configuration & Cache
npm config list | Show current npm configuration |
npm config set registry <url> | Set custom registry URL |
npm config get prefix | Show global install directory |
npm cache clean --force | Clear npm cache |
npm cache verify | Verify cache integrity |
npm root -g | Show global node_modules path |
npm doctor | Run diagnostics on npm setup |
8Security & Audit
npm audit | Check for known vulnerabilities |
npm audit fix | Auto-fix vulnerabilities |
npm audit fix --force | Fix vulnerabilities (breaking changes allowed) |
npm audit --json | Output audit results as JSON |
npm token list | List active authentication tokens |
npm whoami | Show currently logged-in user |
Related Cheatsheets
JavaScript ES6+
Modern JavaScript syntax: destructuring, arrow functions, promises, modules, and built-in methods
Python Essentials
Python syntax, data structures, comprehensions, built-in functions, and common patterns
Regular Expressions
Regex syntax, character classes, quantifiers, groups, lookaheads, and common patterns