@0xcda7a/npm 中文文档教程
npm(1) -- a JavaScript package manager
SYNOPSIS
这足以让您启动并运行。
安装后可通过 npm help
获得更多信息。
IMPORTANT
您需要节点 v4 或更高版本才能运行此程序。
要安装可在节点 v0.12 上运行的旧且不受支持的 npm 版本 之前,克隆 git repo 并挖掘旧标签和分支。
npm 配置为使用 npm, Inc. 的公共包注册表,网址为 https://registry.npmjs.org 默认情况下。
您可以将 npm 配置为使用任何兼容的注册表 喜欢,甚至运行您自己的注册表。 查看 文档 注册表。
使用他人的注册表可能受使用条款约束。 这 默认公共注册表的使用条款可在 https://www.npmjs.com。
Super Easy Install
npm 与 node 捆绑在一起。
Windows Computers
获取 MSI。 npm 在里面。
Apple Macintosh Computers
获取 pkg。 npm 在里面。
Other Sorts of Unices
运行 安装
。 npm 将与节点一起安装。
如果你想要更花哨的裤子安装(不同版本,定制 路径等)然后继续阅读。
Fancy Install (Unix)
有一个非常强大的安装脚本 https://www.npmjs.com/install.sh。 你可以下载并运行它。
这是一个使用 curl 的示例:
curl -L https://www.npmjs.com/install.sh | sh
Slightly Fancier
您可以使用该脚本设置任何 npm 配置参数:
npm_config_prefix=/some/path sh install.sh
或者,您可以在 uber-debuggery 模式下运行它:
npm_debug=1 sh install.sh
Even Fancier
使用 git 获取代码。 使用 make
构建文档和做其他事情。 如果你打算对 npm 进行黑客攻击,make link
是你的朋友。
如果你有npm源码,也可以半永久设置 使用 ./configure --key=val ...
任意配置键,然后 通过执行 node bin/npm-cli.js
Windows Install or Upgrade
在 npm 3 中为 Windows 用户进行了许多改进 - 你将拥有更好的 如果您运行最新版本的 npm,请体验一下。 要升级,请使用 Microsoft 的 升级工具, 下载新版本的 Node, 或按照 Windows 升级说明进行操作 npm 故障排除指南。
如果这对你来说还不够花哨,那么你可以获取代码 git,直接搞砸了。
Installing on Cygwin
不
Uninstalling
,看到你离开我很难过。
sudo npm uninstall npm -g
或者,如果失败,
sudo make uninstall
More Severe Uninstalling
通常,上述说明就足够了。 那将删除 npm,但留下你安装的任何东西。
如果您想删除所有已安装的软件包, 然后你可以使用 npm ls
命令找到它们,然后 npm rm
到 删除它们。
要删除 npm 0.x 留下的 cruft,您可以使用包含的 clean-old.sh
脚本文件。 您可以像这样方便地运行它:
npm explore npm -g -- sh scripts/clean-old.sh
npm 使用两个配置文件,一个用于每个用户配置,另一个 对于全局(每个用户)配置。 您可以通过执行以下操作查看它们:
npm config get userconfig # defaults to ~/.npmrc
npm config get globalconfig # defaults to /usr/local/etc/npmrc
默认情况下,卸载 npm 不会删除配置文件。 你 如果你想让它们消失,你必须自己手动移除它们。 注意 这意味着未来的 npm 安装将不会记住那些设置 你已经选择。
More Docs
查看文档。
您可以使用 npm help
命令来阅读它们中的任何一个。
如果你是一名开发者,并且你想使用 npm 来发布你的程序, 你应该阅读这个。
BUGS
当您发现问题时,请报告它们:
确保包括 所有 无效的 npm 命令的输出 正如预期的那样。 npm-debug.log
文件也有助于提供。
您还可以在 https://package.community/ 上的 #npm
中找到 npm 人员,或者 在推特上。 谁回应谁就不会 怀疑告诉您将输出放在要点或电子邮件中。
SEE ALSO
- npm(1)
- npm-help(1)
- npm-index(7)
npm(1) -- a JavaScript package manager
SYNOPSIS
This is just enough info to get you up and running.
Much more info available via npm help
once it's installed.
IMPORTANT
You need node v4 or higher to run this program.
To install an old and unsupported version of npm that works on node v0.12 and prior, clone the git repo and dig through the old tags and branches.
npm is configured to use npm, Inc.'s public package registry at https://registry.npmjs.org by default.
You can configure npm to use any compatible registry you like, and even run your own registry. Check out the doc on registries.
Use of someone else's registry may be governed by terms of use. The terms of use for the default public registry are available at https://www.npmjs.com.
Super Easy Install
npm is bundled with node.
Windows Computers
Get the MSI. npm is in it.
Apple Macintosh Computers
Get the pkg. npm is in it.
Other Sorts of Unices
Run make install
. npm will be installed with node.
If you want a more fancy pants install (a different version, customized paths, etc.) then read on.
Fancy Install (Unix)
There's a pretty robust install script at https://www.npmjs.com/install.sh. You can download that and run it.
Here's an example using curl:
curl -L https://www.npmjs.com/install.sh | sh
Slightly Fancier
You can set any npm configuration params with that script:
npm_config_prefix=/some/path sh install.sh
Or, you can run it in uber-debuggery mode:
npm_debug=1 sh install.sh
Even Fancier
Get the code with git. Use make
to build the docs and do other stuff. If you plan on hacking on npm, make link
is your friend.
If you've got the npm source code, you can also semi-permanently set arbitrary config keys using the ./configure --key=val ...
, and then run npm commands by doing node bin/npm-cli.js <command> <args>
. (This is helpful for testing, or running stuff without actually installing npm itself.)
Windows Install or Upgrade
Many improvements for Windows users have been made in npm 3 - you will have a better experience if you run a recent version of npm. To upgrade, either use Microsoft's upgrade tool, download a new version of Node, or follow the Windows upgrade instructions in the npm Troubleshooting Guide.
If that's not fancy enough for you, then you can fetch the code with git, and mess with it directly.
Installing on Cygwin
No.
Uninstalling
So sad to see you go.
sudo npm uninstall npm -g
Or, if that fails,
sudo make uninstall
More Severe Uninstalling
Usually, the above instructions are sufficient. That will remove npm, but leave behind anything you've installed.
If you would like to remove all the packages that you have installed, then you can use the npm ls
command to find them, and then npm rm
to remove them.
To remove cruft left behind by npm 0.x, you can use the included clean-old.sh
script file. You can run it conveniently like this:
npm explore npm -g -- sh scripts/clean-old.sh
npm uses two configuration files, one for per-user configs, and another for global (every-user) configs. You can view them by doing:
npm config get userconfig # defaults to ~/.npmrc
npm config get globalconfig # defaults to /usr/local/etc/npmrc
Uninstalling npm does not remove configuration files by default. You must remove them yourself manually if you want them gone. Note that this means that future npm installs will not remember the settings that you have chosen.
More Docs
Check out the docs.
You can use the npm help
command to read any of them.
If you're a developer, and you want to use npm to publish your program, you should read this.
BUGS
When you find issues, please report them:
Be sure to include all of the output from the npm command that didn't work as expected. The npm-debug.log
file is also helpful to provide.
You can also find npm people in #npm
on https://package.community/ or on Twitter. Whoever responds will no doubt tell you to put the output in a gist or email.
SEE ALSO
- npm(1)
- npm-help(1)
- npm-index(7)