ToolStack
KO

npm Commands Cheatsheet

npm package management, scripts, npx, and yarn/pnpm equivalents

Your data never leaves the browser — all processing is done locally 0 server requests

01

Project Initialization

  • npm init -y

    Create package.json immediately with default values

  • npm init

    Create package.json interactively

  • npm create vite@latest

    Scaffold a new Vite-based project

  • npx create-react-app 앱이름

    Create a new React app (CRA)

02

Package Installation

  • npm install

    Install all dependencies listed in package.json

  • npm install 패키지명

    Install a package and add it to dependencies

  • npm install -D 패키지명

    Install a package and add it to devDependencies (build tools, etc.)

  • npm install -g 패키지명

    Install a package globally

  • npm install 패키지명@1.2.3

    Install a specific version of a package

  • npm install 패키지명@latest

    Install the latest version of a package

  • npm ci

    Install exact versions from package-lock.json (recommended for CI)

03

Package Removal & Update

  • npm uninstall 패키지명

    Remove a package and delete it from package.json

  • npm update

    Update all packages within their allowed version ranges

  • npm update 패키지명

    Update a specific package

  • npm outdated

    Check which packages have newer versions available

04

Running Scripts

  • npm run 스크립트명

    Run a script defined in package.json scripts

  • npm start

    Run the start script (e.g., dev server)

  • npm run build

    Run the build script (production build)

  • npm test

    Run the test script

  • npx 패키지명 [옵션]

    Run a package temporarily without installing it

05

Package Lookup & Info

  • npm list

    Print the dependency tree for the current project

  • npm list --depth=0

    Show only top-level installed packages

  • npm list -g --depth=0

    List globally installed packages

  • npm info 패키지명

    Fetch package info from the npm registry

  • npm view 패키지명 versions

    List all available versions of a package

06

Cache & Configuration

  • npm cache clean --force

    Force-clear the npm cache (useful for fixing install errors)

  • npm config list

    Print the current npm configuration

  • npm config set registry https://registry.npmjs.org/

    Reset the npm registry to the default

  • npm audit

    Scan for security vulnerabilities

  • npm audit fix

    Automatically patch fixable vulnerabilities

07

yarn / pnpm Equivalents

Equivalent commands when using yarn or pnpm instead of npm

  • yarn add 패키지명

    yarn: Install a package (equivalent to npm install <pkg>)

  • yarn add -D 패키지명

    yarn: Install a package as a dev dependency

  • pnpm add 패키지명

    pnpm: Install a package (optimized disk efficiency)

  • pnpm install

    pnpm: Install all dependencies

npm: package.json Is Your Project's Blueprint

npm is the standard package manager for the Node.js ecosystem. The core workflow — npm install to set up dependencies, npm run build/start to execute scripts — applies to almost every JavaScript and TypeScript project. Always commit package-lock.json so teammates install identical versions.

yarn and pnpm use the same concepts but different internals. pnpm's content-addressable store dramatically reduces disk usage across projects and speeds up installs. Monorepos benefit from npm workspaces, yarn workspaces, or pnpm workspaces.

FAQ

What is the difference between npm install and npm ci?
npm install reads package.json and may update package-lock.json. npm ci reads package-lock.json exactly, wipes node_modules first, and installs precisely — no lock file changes. Use npm ci in CI/CD pipelines for reproducible builds.
Which should I use: npm, yarn, or pnpm?
npm ships with Node.js and needs no extra setup. yarn has strong workspaces support. pnpm uses hard links to save disk space and is significantly faster. Follow your team's choice; for a new project, pnpm is a great default.
What is the difference between npx and npm run?
npm run executes scripts defined in the scripts field of package.json. npx runs a package's binary from node_modules or downloads it temporarily from the registry. npx is ideal for one-off tools like create-react-app.

Related Tools