npm Commands Cheatsheet — Package Manager Reference

npm commands: install, update, publish, scripts, workspaces, security audit. Including npx and package.json guide.

Package Management

CommandDescription
npm init -yCreate package.json
npm install <pkg>Install dependency
npm install -D <pkg>Install dev dependency
npm install -g <pkg>Install globally
npm uninstall <pkg>Remove package
npm updateUpdate all packages
npm outdatedCheck for outdated packages
npm ls --depth=0List installed packages

Scripts & Running

// package.json
{
  "scripts": {
    "dev": "node --watch server.js",
    "build": "tsc",
    "test": "jest",
    "lint": "eslint .",
    "start": "node dist/server.js"
  }
}

// Run scripts
npm run dev
npm test        // Shorthand (also: npm start, npm stop)
npm run build

npx — Run Without Installing

npx create-react-app my-app
npx ts-node script.ts
npx eslint --init

Security

npm audit              # Check for vulnerabilities
npm audit fix          # Auto-fix vulnerabilities
npm audit fix --force  # Force fix (may break things)

Publishing

npm login
npm publish
npm publish --access public  # For scoped packages
npm version patch|minor|major

Need These Tools as an API?

TextForge API offers 20+ developer toolkit endpoints. Free tier: 50 requests/day.

Try TextForge API Free →

Related Tools