npm

Synopsis提要
npm
Note: This command is unaware of workspaces.注意:此命令不知道工作空间。

Version版本
9.6.3

Description描述
npm is the package manager for the Node JavaScript platform. npm是NodeJavaScript平台的包管理器。It puts modules in place so that node can find them, and manages dependency conflicts intelligently.它将模块放置在适当的位置,以便节点能够找到它们,并智能地管理依赖冲突。
It is extremely configurable to support a variety of use cases. Most commonly, you use it to publish, discover, install, and develop node programs.它非常可配置,可以支持各种用例。最常见的情况是,您可以使用它来发布、发现、安装和开发节点程序。
Run 运行npm help
to get a list of available commands.npm help
以获取可用命令的列表。

Important重要的
npm comes preconfigured to use npm's public registry at https://registry.npmjs.org by default. Use of the npm public registry is subject to terms of use available at https://docs.npmjs.com/policies/terms.npm预先配置为使用npm的公共注册表,默认情况下位于https://registry.npmjs.org。npm公共注册处的使用受https://docs.npmjs.com/policies/terms的使用条款约束。
You can configure npm to use any compatible registry you like, and even run your own registry. 您可以将npm配置为使用任何您喜欢的兼容注册表,甚至可以运行自己的注册表。Use of someone else's registry is governed by their terms of use.使用他人的注册表受其使用条款的约束。

Introduction介绍
You probably got npm because you want to install stuff.你得到npm可能是因为你想安装一些东西。
The very first thing you will most likely want to run in any node program is 最有可能在任何节点程序中运行的第一件事就是npm install
to install its dependencies.npm install
来安装其依赖项。
You can also run 您也可以运行npm install blerg
to install the latest version of "blerg". npm install blerg
来安装最新版本的“blerg”。Check out npm install for more info. 查看npm install了解更多信息。It can do a lot of stuff.它可以做很多事情。
Use the 使用npm search
command to show everything that's available in the public registry. npm search
命令可以显示公共注册表中可用的所有内容。Use 使用npm ls
to show everything you've installed.npm ls
显示您已安装的所有内容。

Dependencies依赖项
If a package lists a dependency using a git URL, npm will install that dependency using the git command and will generate an error if it is not installed.如果一个包使用git URL列出了一个依赖项,npm将使用git命令安装该依赖项,如果没有安装,则会生成一个错误。
If one of the packages npm tries to install is a native node module and requires compiling of C++ Code, npm will use node-gyp for that task. 如果npm尝试安装的包之一是本机节点模块,并且需要编译C++代码,则npm将使用node-gyp执行该任务。For a Unix system, node-gyp needs Python, make and a buildchain like GCC. 对于Unix系统,node-gyp需要Python、make和类似GCC的构建链。On Windows, Python and Microsoft Visual Studio C++ are needed. 在Windows上,需要Python和Microsoft Visual Studio C++。For more information visit the node-gyp repository and the node-gyp Wiki.有关更多信息,请访问node-gyp存储库和node-gyp Wiki。

Directories目录
See folders to learn about where npm puts stuff.查看文件夹以了解npm将内容放在何处。
In particular, npm has two modes of operation:特别是,npm有两种操作模式:
local mode: npm installs packages into the current project directory, which defaults to the current working directory.本地模式:npm将包安装到当前项目目录中,默认为当前工作目录。Packages install to程序包安装到./node_modules
, and bins to./node_modules/.bin
../node_modules
和bin到./node_modules/.bin
。global mode: npm installs packages into the install prefix at全局模式:npm将软件包安装到$npm_config_prefix/lib/node_modules
and bins to$npm_config_prefix/bin
.$npm_config_prefix/lib/node_modules
的安装前缀中,并将bins安装到$npm_config_prefix/bin
。
Local mode is the default. 本地模式是默认模式。Use 在任何命令上使用-g
or --global
on any command to run in global mode instead.-g
或--global
可以改为在全局模式下运行。

Developer Usage开发人员使用
If you're using npm to develop and publish your code, check out the following help topics:如果您使用npm来开发和发布代码,请查看以下帮助主题:
json: Make a package.json file.json:制作一个package.json文件。See package.json.请参阅package.json。link: Links your current working code into Node's path, so that you don't have to reinstall every time you make a change.链接:将您当前的工作代码链接到Node的路径,这样您就不必每次更改都重新安装。Use npm link to do this.使用npm link来完成此操作。install: It's a good idea to install things if you don't need the symbolic link.install:如果你不需要符号链接,安装一些东西是个好主意。Especially, installing other peoples code from the registry is done via npm install特别是,从注册表中安装其他人的代码是通过npm install完成的adduser: Create an account or log in.adduser:创建帐户或登录。When you do this, npm will store credentials in the user config file.当您这样做时,npm将在用户配置文件中存储凭据。publish: Use the npm publish command to upload your code to the registry.publish:使用npm publish命令将代码上载到注册表。

Configuration配置
npm is extremely configurable. npm是非常可配置的。 It reads its configuration options from 5 places.它从5个位置读取其配置选项。
Command line switches: Set a config with命令行开关:使用--key val
.--key val
设置配置。All keys take a value, even if they are booleans (the config parser doesn't know what the options are at the time of parsing).所有键都有一个值,即使它们是布尔值(配置解析器在解析时不知道选项是什么)。If you do not provide a value (如果不提供值(--key
) then the option is set to booleantrue
.--key
),则该选项将设置为布尔值true
。Environment Variables: Set any config by prefixing the name in an environment variable with环境变量:通过在环境变量的名称前加npm_config_
.npm_config_
来设置任何配置。For example,例如,export npm_config_key=val
.export npm_config_key=val
。User Configs: The file at用户配置:$HOME/.npmrc
is an ini-formatted list of configs.$HOME/.npmrc
中的文件是ini格式的配置列表。If present, it is parsed.如果存在,则对其进行解析。If the如果在cli或env中设置了userconfig
option is set in the cli or env, that file will be used instead.userconfig
选项,则将使用该文件。Global Configs: The file found at全局配置:在找到文件./etc/npmrc
(relative to the global prefix will be parsed if it is found../etc/npmrc
(相对于全局前缀,如果找到就会解析。See npm prefix for more info on the global prefix.有关全局前缀的更多信息,请参阅npm prefix。If the如果在cli、env或user-config中设置了globalconfig
option is set in the cli, env, or user config, then that file is parsed instead.globalconfig
选项,则会解析该文件。Defaults: npm's default configuration options are defined in默认值:npm的默认配置选项在lib/utils/config/definitions.js
.lib/utils/config/definitions.js
中定义。These must not be changed.这些决不能改变。
See config for much much more information.有关更多信息,请参阅config。

Contributions捐款
Patches welcome!欢迎补丁!
If you would like to help, but don't know what to work on, read the contributing guidelines and check the issues list.如果你想提供帮助,但不知道该做什么,请阅读贡献指南并查看问题列表。
Bugs
When you find issues, please report them: 当您发现问题时,请报告:https://github.com/npm/cli/issues
Please be sure to follow the template and bug reporting guidelines.请务必遵循模板和错误报告指南。

Feature Requests功能请求
Discuss new feature ideas on our discussion forum:在讨论论坛上讨论新功能理念:
Or suggest formal RFC proposals:或者建议正式的RFC提案: