更新 NPM 时出错

更新 NPM 时出错

phonegap我正在尝试在 Ubuntu 14.04 中安装,当我尝试更新 NPM 时,我总是收到此错误。这可能是什么?如何修复?

我正在使用的命令是sudo npm npm update -g并且sudo npm npm install -g总是出现这个错误:

npm ERR! tar pack Error reading /home/alisson/tmp/npm-13231/1456521975198-0.6208237137179822/package
npm ERR! TypeError: Cannot call method 'filter' of undefined
npm ERR!     at Packer.IgnoreReader.addIgnoreRules (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:148:13)
npm ERR!     at Packer.IgnoreReader.addIgnoreFile (/usr/local/lib/node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js:133:10)
npm ERR!     at fs.readFile (fs.js:176:14)
npm ERR!     at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:5)
npm ERR!     at Object.oncomplete (fs.js:297:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.16.0-60-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "update" "npm" "-g"
npm ERR! cwd /home/alisson/.local/share/Trash/files/npm
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! type non_object_property_call
npm ERR! addLocalDirectory Could not pack "/home/alisson/tmp/npm-13231/1456521975198-0.6208237137179822/package" to "/home/alisson/.npm/npm/3.7.5/package.tgz"
npm ERR! Error: Callback called more than once.
npm ERR!     at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:80:16)
npm ERR!     at asyncMap (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:27:18)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/update.js:29:5
npm ERR!     at /usr/local/lib/node_modules/npm/lib/outdated.js:33:30
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR!     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Linux 3.16.0-60-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "update" "npm" "-g"
npm ERR! cwd /home/alisson/.local/share/Trash/files/npm
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/alisson/.local/share/Trash/files/npm/npm-debug.log
npm ERR! not ok code 0

该文件夹npm-13231/1456521975198-0.6208237137179822/package存在于目录中tmp

答案1

我遇到了类似的问题。看来你正在使用不再受支持的旧版 npm。(根据上一篇帖子这个 GitHub 问题)。

我建议完全卸载 npm 并重新安装最新版本。

要卸载 node 和 npm(如果 npm 与你的 node 安装捆绑在一起),请尝试sudo apt-get remove nodejs。(要重新安装最新版本,参见 MorganGalpin 的回答这个 Stack Overflow 问题

要仅卸载 npm,请尝试npm rm npm -g(全局删除 npm)或make uninstall在安装 npm 的文件夹中(which npm将告诉您它在哪里)。

相关内容