错误

  • npm 安装失败(Broken npm installation)
  • 随机错误(Random errors)
  • 没有发现兼容的版本(No compatible version found)
  • 权限错误(permissions error)
  • 在 window7 Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm
  • 没有空间(no space)
  • 没有git
  • 由于路径长度问题,在Windows上运行“ Vagrant”框失败
  • npm only uses git: and ssh+git: URLs for GitHub repos, breaking proxies
  • SSL error
  • Not found / Server error
  • 无效 JSON
  • 输出中出现许多 ENOENT / ENOTEMPTY 错误
  • 当你使用 shrinkwrapped 依赖的时候 cb() never calles!
  • npm 登录错误
  • npm 在 Windows 的 addRemoteTarball 被挂起
  • 在 Windows 设备上,npm 没有运行最新的版本

npm 安装失败(Broken npm installation)

如果你的 npm 损坏了:

  • 在 Mac 或者 Linux,重新装安装 npm
  • Windows:如果你在使用Windows 并且安装失败了,最简单的方式是通过官方的下载器重新安装 node (查看 this note about installing the latest stable version

    随机错误

  • 一些奇奇怪怪的问题可以通过运行 npm cache clean 来解决

  • 如果你在使用 npm install 的时候遇到问题,使用 -verbose 选项来查看更多的细节

没有发现兼容的版本

你的 npm 已经过时了,请升级为 最近新的稳定版 npm

权限错误

请查看 下载与安装 Node.js 与 npm 以及 解决 npm 在全局安装包时出现的权限错误 来找到解决权限错误的方法。

在 window7 Error: ENOENT, stat 'C:\Users\<user>\AppData\Roaming\npm

你可以在 joyent/node#8141 找到这个问题的解决方案,这是 Windows 的Node 安装器的问题。解决的方案就是确保 C:\Users\<user>\AppData\Roaming\npm 存在 并且普通的账户能写入。

没有空间(no space)

  1. npm ERR! Error: ENOSPC, write

你试图将 npm 安装在空间不足或者是没有权限写入的磁盘。

  • 释放一些磁盘的空间
  • 在其它有空间的地方设置一个 tmp 文件夹:npm config set tmp /path/to/big/drive/tmp
  • 自己构建Node并将其安装在可写的空间很大的地方。

没有git

  1. npm ERR! not found: git
  2. ENOGIT

你需要去安装 git 。或者你需要去将你的 git information 添加到 你的 npm profile 内。你可以在命令行或者是网站上完成修改操作。更多的信息可以查看 管理你的 profile 设置

由于路径长度问题,在Windows上运行“ Vagrant”框失败

…..

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

….

SSL Error

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

你尝试将 SSL 与未加密的端点进行通信。通常(more often than not),这样会导致 代理配置错误(另请参阅:有点过时但有用的教程)。

在这种情况下,请不要去关闭 strict-ssl —— 你可能需要设置 CA/CA 文件 与你的代理一起使用,花点时间弄清楚这一点比禁用SSL保护要好得多。

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

这个问题将会发生在你运行 Node 0.6 的时候,请你升级到 Node 0.8 或者更高。查看这篇博文了解更多

你也可以尝试这个解决方案:npm config set ca "" 或者 npm config set strict-ssl false

  1. npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN

npm 不再支持 self-signed certificates

  • 升级你的npm版本 npm install npm -g --ca=""
  • 告诉你当前的 npm 版本给 registry的管理员 npm config set ca=""

如果这没有解决你的问题,you may have an SSL-intercepting proxy。
(比如:https://github.com/npm/npm/issues/7439#issuecomment-76024878

SSL-intercepting proxy

Unsolved. Seehttps://github.com/npm/npm/issues/9282

Not found / Server error

  1. npm http 404 https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
  2. npm ERR! fetch failed https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.7.0.tgz
  3. npm ERR! Error: 404 Not Found
  1. npm http 500 https://registry.npmjs.org/phonegap
  • 这看起来更像是 npm registry 短期的失灵。检查 npm server status 然后重试
  • 如果这个错误持续存在,或许这个是上传的包有问题。联系这个包的所有者并且让他们上传一个新的版本。