Npm Cheatsheet

Npm package manager commands and package.json configuration

Node.js6 commandsbeginner

Overview

Npm manages JavaScript packages from the npm registry.

Why It Matters

Npm is the package manager for JavaScript and Node.js ecosystem.

Essential Commands

npm init -y

Create package.json with defaults

npm install

Install dependencies from package-lock/package.json

npm install <package>

Add dependency to project

npm install -D <package>

Add development dependency

npm run dev

Run development script

npm run build

Run production build script

Quick Start

Begin by learning install, update, and remove packages

Key Concepts

Install, update, and remove packages

Manage dependencies and devDependencies

Create and publish npm packages

Pro Tips

  • Combine multiple commands for powerful workflows
  • Use aliases to speed up your command entry
  • Create scripts to automate repetitive tasks

Common Pitfalls to Avoid

  • Forgetting to check the documentation for edge cases
  • Running commands without understanding their full impact
  • Not testing changes in a safe environment first

Related Resources

10 items