Skip to main content

npm & Yarn

Package manager commands for Node.js

DevOps

Project Setup

npm init

Create package.json

npm init -y

Create with defaults

yarn init

Create with Yarn

Install Packages

npm install

Install all dependencies

npm install <pkg>

Install package

npm install -D <pkg>

Install as devDependency

npm install -g <pkg>

Install globally

yarn add <pkg>

Yarn install package

yarn add -D <pkg>

Yarn devDependency

Remove & Update

npm uninstall <pkg>

Remove package

npm update

Update all packages

npm update <pkg>

Update specific package

npm outdated

Check outdated packages

yarn remove <pkg>

Yarn remove

yarn upgrade

Yarn update all

Scripts & Running

npm run <script>

Run script from package.json

npm start

Run start script

npm test

Run test script

npm run build

Run build script

npx <cmd>

Run package without install

Info & Management

npm list

List installed packages

npm list -g

List global packages

npm info <pkg>

Package information

npm cache clean --force

Clear cache

npm audit

Security audit

npm audit fix

Fix vulnerabilities

Privacy-First Developer Toolkits - 35+ Browser-Based Tools