← 返回命令列表

Linux command

npm 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Install dependencies

npm install

Install package

npm install [package]

Install globally

npm install -g [package]

Install dev dependency

npm install -D [package]

Run script

npm run [script-name]

Start application

npm start

Run tests

npm test

Update packages

npm update

Initialize project

npm init

Clean install from lockfile

npm ci

List installed packages

npm ls

Check for outdated packages

npm outdated

说明

npm is the Node Package Manager and the default package manager for Node.js. It manages JavaScript packages and dependencies using package.json and package-lock.json files. npm provides access to the world's largest software registry with over two million packages.

参数

install
Install packages.
uninstall
Remove packages.
run _SCRIPT_
Run package script.
update
Update packages.
init
Create package.json.
ci
Clean install from package-lock.json (for CI/CD).
audit
Run security vulnerability audit.
ls
List installed packages.
outdated
Check for outdated packages.
publish
Publish package to registry.
-g
Global installation.
-D, --save-dev
Save as development dependency.
--help
Display help information.

FAQ

What is the npm command used for?

npm is the Node Package Manager and the default package manager for Node.js. It manages JavaScript packages and dependencies using package.json and package-lock.json files. npm provides access to the world's largest software registry with over two million packages.

How do I run a basic npm example?

Run `npm install` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does install do in npm?

Install packages.