“npm i”命令是做什么用的?

109

i 命令在 npm CLI 中是用来做什么的?

我看到它被这样使用:

npm i package
2个回答

97

i标志是install的别名,因此

npm i package

与...相同

npm install package

来自文档:

npm install (with no args, in package dir)
npm install [<@scope>/]<name>
npm install [<@scope>/]<name>@<tag>
npm install [<@scope>/]<name>@<version>
npm install [<@scope>/]<name>@<version range>
npm install <alias>@npm:<name>
npm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
npm install <tarball file>
npm install <tarball url>
npm install <folder>

aliases: npm i, npm add
common options: [-P|--save-prod|-D|--save-dev|-O|--save-optional|--save-peer] [-E|--save-exact] [-B|--save-bundle] [--no-save] [--dry-run]

--save-peer已经不再存在。请参考https://docs.npmjs.com/cli/v10/commands/npm-install。 - undefined

25

i 命令是 npm-install 的别名,文档中有提到

你可以与所有 npm-install 标志一起使用。例如,下面的示例将使用 npm i 命令安装 Angularlive-server

npm i angular2@2.0.0-alpha.45 -E
npm i live-server -D

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接