A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-bash/zsh: npm command not found # Windows (WSL2) sudo apt-get update sudo apt-get install npm # Debian apt-get install npm # Ubuntu apt-get install npm # Alpine apk add npm # Arch Linux pacman -S npm # Kali Linux apt-get install npm # Fedora dnf install npm-1 # Raspbian apt-get install npm # Dockerfile dockerfile.run/npm # Docker docker run cmd.cat/npm npm
npm 是 JavaScript 和 Node.js 包管理器。管理 Node.js 项目及其模块依赖项。npm 是世界上最大的软件注册中心。各大洲的开源开发者都使用 npm 来共享和借用软件包,许多组织也使用 npm 来管理私有开发。
npm <command>
npm install install all the dependencies in your project
npm install <foo> add the <foo> dependency to your project
npm test run this project's tests
npm run <foo> run the script named <foo>
npm <command> -h quick help on <command>
npm -l display usage info for all commands
npm help <term> search for help on <term> (in a browser)
npm help npm more involved overview (in a browser)
All commands:
access, adduser, audit, bugs, cache, ci, completion,
config, dedupe, deprecate, diff, dist-tag, docs, doctor,
edit, exec, explain, explore, find-dupes, fund, get, help,
help-search, hook, init, install, install-ci-test,
install-test, link, ll, login, logout, ls, org, outdated,
owner, pack, ping, pkg, prefix, profile, prune, publish,
query, rebuild, repo, restart, root, run-script, sbom,
search, set, shrinkwrap, star, stars, start, stop, team,
test, token, uninstall, unpublish, unstar, update, version,
view, whoami
Specify configs in the ini-formatted file:
or on the command line via: npm <command> --key=value
More configuration info: npm help config
Configuration fields: npm help 7 config
npm 以交互方式创建 package.json 文件:
npm init
npm 下载 package.json 中列出的所有依赖包:
npm install
npm 下载包的特定版本并将其添加到 package.json 中的依赖项列表中:
npm install package_name@version
npm 下载软件包的最新版本并将其添加到 package.json 中的开发依赖项列表中:
npm install package_name --save-dev
npm 下载软件包的最新版本并全局安装:
npm install --global package_name
npm 卸载一个包并将其从 package.json 中的依赖项列表中删除:
npm uninstall package_name
npm 本地安装的依赖项列表:
npm list
npm 列出顶级全局安装的包:
npm list --global --depth=0