错误

Errors

损坏的 npm 安装

Broken npm installation

如果你的 npm 坏了:

If your npm is broken:

随机错误

Random errors

  • 一些奇怪的问题可以通过简单地运行 npm cache clean 并重试来解决。

    Some strange issues can be resolved by simply running npm cache clean and trying again.

  • 如果你在使用 npm install 时遇到问题,请使用 -verbose 选项查看更多详细信息。

    If you are having trouble with npm install, use the -verbose option to see more details.

未找到兼容版本

No compatible version found

你有一个过时的 npm。请更新到最新的稳定 npm

You have an outdated npm. Please update to the latest stable npm.

权限错误

Permissions errors

请参阅“下载和安装 Node.js 和 npm”和“解决全局安装包时的 EACCES 权限错误”中的讨论,了解避免和解决权限错误的方法。

Please see the discussions in "Downloading and installing Node.js and npm" and "Resolving EACCES permissions errors when installing packages globally" for ways to avoid and resolve permissions errors.

Windows 7 上的 Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm'

Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm' on Windows 7

Windows 7 上的错误 Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm'joyent/node#8141 的结果,并且是 Windows 的 Node 安装程序的问题。解决方法是确保 C:\Users\<user>\AppData\Roaming\npm 存在并且可以使用你的普通用户账户写入。

The error Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm' on Windows 7 is a consequence of joyent/node#8141, and is an issue with the Node installer for Windows. The workaround is to ensure that C:\Users\<user>\AppData\Roaming\npm exists and is writable with your normal user account.

没有空间

No space

npm ERR! Error: ENOSPC, write

你正在尝试安装在没有空间或没有写入权限的驱动器上。

You are trying to install on a drive that either has no space, or has no permission to write.

  • 释放一些磁盘空间或

    Free some disk space or

  • 将 tmp 文件夹设置在有更多空间的地方:npm config set tmp /path/to/big/drive/tmp

    Set the tmp folder somewhere with more space: npm config set tmp /path/to/big/drive/tmp or

  • 自己构建 Node 并将其安装在具有大量空间的可写位置。

    Build Node yourself and install it somewhere writable with lots of space.

没有 git

No git

npm ERR! not found: git
ENOGIT

你需要 安装 git。或者,你可能需要将你的 git 信息添加到你的 npm 配置文件中。你可以从命令行或网站执行此操作。欲了解更多信息,请参阅“管理个人资料设置”。

You need to install git. Or, you may need to add your git information to your npm profile. You can do this from the command line or the website. For more information, see "Managing your profile settings".

由于路径长度问题,在 Windows 上运行 Vagrant 盒子失败

Running a Vagrant box on Windows fails due to path length issues

@drmyersii 经历了很多听起来很痛苦的试验和错误,提出了一个涉及 Windows 长路径和一些自定义 Vagrant 配置的工作解决方案:

@drmyersii went through what sounds like a lot of painful trial and error to come up with a working solution involving Windows long paths and some custom Vagrant configuration:

这是我实现它的提交,但我会继续在此处发布主要代码片段:

This is the commit that I implemented it in, but I'll go ahead and post the main snippet of code here:

config.vm.provider "virtualbox" do |v|
v.customize ["sharedfolder", "add", :id, "--name", "www", "--hostpath", (("//?/" + File.dirname(__FILE__) + "/www").gsub("/","\\"))]
end
config.vm.provision :shell, inline: "mkdir /home/vagrant/www"
config.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` > www /home/vagrant/www", run: "always"

在上面的代码中,我将 \\?\ 附加到当前目录绝对路径。这实际上将强制 Windows API 允许增加 MAX_PATH 变量(通常上限为 260)。阅读有关 最大路径 的更多信息。这发生在由 VBoxManage 而不是 Vagrant 的 "synced_folder" 方法有意处理的共享文件夹创建期间。最后一点是不言自明的;我们创建新的共享文件夹,然后确保每次访问或触摸机器时都挂载它,因为 Vagrant 喜欢在每次加载时重新加载其挂载/共享文件夹。

In the code above, I am appending \\?\ to the current directory absolute path. This will actually force the Windows API to allow an increase in the MAX_PATH variable (normally capped at 260). Read more about max path. This is happening during the sharedfolder creation which is intentionally handled by VBoxManage and not Vagrant's "synced_folder" method. The last bit is pretty self-explanatory; we create the new shared folder and then make sure it's mounted each time the machine is accessed or touched since Vagrant likes to reload its mounts/shared folders on each load.

npm 仅将 git:ssh+git: URL 用于 GitHub 存储库,破坏代理

npm only uses git: and ssh+git: URLs for GitHub repos, breaking proxies

@LaurentGoderre一些 Git 技巧 解决了这个问题:

@LaurentGoderre fixed this with some Git trickery:

我通过运行以下两个命令为我的几个同事解决了这个问题:

I fixed this issue for several of my colleagues by running the following two commands:

git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

我们注意到的一件事是使用的 .gitconfig 并不总是预期的,因此如果你使用的机器将主路径修改为共享驱动器,则需要确保共享驱动器和 c:\users\[your user]\ 中的 .gitconfig 相同

One thing we noticed is that the .gitconfig used is not always the one expected so if you are on a machine that modified the home path to a shared drive, you need to ensure that your .gitconfig is the same on both your shared drive and in c:\users\[your user]\

SSL 错误

SSL Error

npm ERR! Error: 7684:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:787:

你正在尝试将 SSL 与未加密的端点通信。这通常是由于 proxy configuration 错误(另见 这很有帮助,如果过时了,指南)。在这种情况下,你不想禁用 strict-ssl – 你可能需要设置一个 CA / CA 文件以与你的代理一起使用,但花时间弄清楚这一点比禁用 SSL 保护要好得多。

You are trying to talk SSL to an unencrypted endpoint. More often than not, this is due to a proxy configuration error (see also this helpful, if dated, guide). In this case, you do not want to disable strict-ssl – you may need to set up a CA / CA file for use with your proxy, but it's much better to take the time to figure that out than disabling SSL protection.

npm ERR! Error: SSL Error: CERT_UNTRUSTED npm ERR! Error: SSL Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE

如果你运行的是 Node 0.6,则会发生此问题。请升级到 node 0.8 或更高版本。有关详细信息,请参阅此帖子

This problem will happen if you're running Node 0.6. Please upgrade to node 0.8 or above. See this post for details.

你也可以尝试这些解决方法:npm config set ca ""npm config set strict-ssl false

You could also try these workarounds: npm config set ca "" or npm config set strict-ssl false

npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN

npm 不再支持其自签名证书

npm no longer supports its self-signed certificates

任何一个:

Either:

  • 升级你的 npm npm install npm -g --ca="" 版本

    upgrade your version of npm npm install npm -g --ca=""

  • 告诉你当前版本的 npm 使用已知的注册商 npm config set ca=""

    tell your current version of npm to use known registrars npm config set ca=""

如果这不能解决问题,那么你可能有一个 SSL 拦截代理。(例如,https://github.com/npm/npm/issues/7439#issuecomment-76024878)

If this does not fix the problem, then you may have an SSL-intercepting proxy. (For example, https://github.com/npm/npm/issues/7439#issuecomment-76024878)

SSL 拦截代理

SSL-intercepting proxy

未解决。见 https://github.com/npm/npm/issues/9282

Unsolved. See https://github.com/npm/npm/issues/9282

未找到/服务器错误

Not found / Server error

npm http 404 https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
npm ERR! Error: 404 Not Found
npm http 500 https://registry.npmjs.org/phonegap
  • 这很可能是一个临时的 npm 注册表故障。检查 npm 服务器状态 并稍后再试。

    It's most likely a temporary npm registry glitch. Check npm server status and try again later.

  • 如果错误仍然存​​在,则可能是发布的包已损坏。联系包所有者并让他们发布包的新版本。

    If the error persists, perhaps the published package is corrupt. Contact the package owner and have them publish a new version of the package.

无效的 JSON

Invalid JSON

Error: Invalid JSON npm ERR! SyntaxError: Unexpected token < npm ERR! registry error parsing json
  • 可能的临时 npm 注册表故障,或损坏的本地服务器缓存。运行 npm cache clean 和/或稍后再试。

    Possible temporary npm registry glitch, or corrupted local server cache. Run npm cache clean and/or try again later.

  • 这可能是由向 package.json 请求提供 HTML 响应的公司代理引起的。检查 npm 的代理 configuration

    This can be caused by corporate proxies that give HTML responses to package.json requests. Check npm's proxy configuration.

  • 检查你尝试安装的包是否存在问题(例如无效的 package.json)。

    Check that it's not a problem with a package you're trying to install (e.g. invalid package.json).

输出中有许多 ENOENT / ENOTEMPTY 错误

Many ENOENT / ENOTEMPTY errors in output

npm 被编写为在安装时有效地使用资源,其中一部分是它尝试同时执行尽可能多的事情。有时这会导致竞争条件和其他同步问题。从 npm 2.0.0 开始,已经解决了大量此类问题。如果你在日志输出中看到 ENOENT lstatENOENT chmodENOTEMPTY unlink 或类似内容,请尝试将 npm 更新到最新版本。如果问题仍然存在,请查看 npm/npm#6043 并查看是否有人已经讨论过你的问题。

npm is written to use resources efficiently on install, and part of this is that it tries to do as many things concurrently as is practical. Sometimes this results in race conditions and other synchronization issues. As of npm 2.0.0, a very large number of these issues were addressed. If you see ENOENT lstat, ENOENT chmod, ENOTEMPTY unlink, or something similar in your log output, try updating npm to the latest version. If the problem persists, look at npm/npm#6043 and see if somebody has already discussed your issue.

使用收缩封装的依赖时 cb() never called!

cb() never called! when using shrinkwrapped dependencies

看看 议题 #5920我们正在努力修复这个问题,但这是一个相当微妙的竞争条件,并且需要我们一些时间。在我们修复此问题之前,你可以尝试将你的 npm-shrinkwrap.json 文件移开。 这已在 npm@2.1.5 之后的 npm 版本中修复,因此请更新到 npm@latest

Take a look at issue #5920. We're working on fixing this one, but it's a fairly subtle race condition and it's taking us a little time. You might try moving your npm-shrinkwrap.json file out of the way until we have this fixed. This has been fixed in versions of npm newer than npm@2.1.5, so update to npm@latest.

npm login 错误

npm login errors

有时 npm login 会无缘无故地失败。首先要做的是在 https://www.npmjs.com/login 登录并检查你在 npmjs.com 上的电子邮件地址是否与你提供给 npm login 的电子邮件地址相匹配。

Sometimes npm login fails for no obvious reason. The first thing to do is to log in at https://www.npmjs.com/login and check that your e-mail address on npmjs.com matches the email address you are giving to npm login.

如果这不是问题,或者如果你看到消息 "may not mix password_sha and pbkdf2",那么

If that's not the problem, or if you are seeing the message "may not mix password_sha and pbkdf2", then

  1. https://npmjs.com/ 登录

    Log in at https://npmjs.com/

  2. https://npmjs.com/password 处更改密码 – 你甚至可以将其 "change" 更改为相同的密码

    Change password at https://npmjs.com/password – you can even "change" it to the same password

  3. ~/.npmrc 中清除与登录相关的字段 – 例如,通过运行 sed -ie '/registry.npmjs.org/d' ~/.npmrc

    Clear login-related fields from ~/.npmrc – e.g., by running sed -ie '/registry.npmjs.org/d' ~/.npmrc

  4. npm login

它通常似乎有效。

and it generally seems to work.

有关此问题的历史,请参见 https://github.com/npm/npm/issues/6641#issuecomment-72984009

See https://github.com/npm/npm/issues/6641#issuecomment-72984009 for the history of this issue.

在 Windows 上 npm 卡在 addRemoteTarball

npm hangs on Windows at addRemoteTarball

检查你的 .npmrc 中是否设置了两个临时目录:

Check if you have two temp directories set in your .npmrc:

> npm config ls -l

查找定义 tmp 配置变量的行。如果你发现不止一个,请删除除其中一个之外的所有内容。

Look for lines defining the tmp config variable. If you find more than one, remove all but one of them.

有关此异常问题的更多信息,请参见 https://github.com/npm/npm/issues/7590

See https://github.com/npm/npm/issues/7590 for more about this unusual problem.

npm 没有在 Windows 机器上运行最新版本

npm not running the latest version on a Windows machine

请参阅有关 Windows 此处 的部分。

See the section about Windows here.

npm 中文网 - 粤ICP备13048890号