【问题标题】:Error when installing LESS through NPM on Ubuntu在 Ubuntu 上通过 NPM 安装 LESS 时出错
【发布时间】:2014-11-02 03:49:13
【问题描述】:

当我尝试在我的 Ubuntu 14.04 系统上通过 NPM 安装 LESS 时,我收到此错误:

peter@ubuntudevsvr:~$ sudo npm install -g less
[sudo] password for peter:
npm http GET https://registry.npmjs.org/less
npm ERR! Error: failed to fetch from registry: less
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/peter/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.11.0-20-generic
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "less"
npm ERR! cwd /home/peter
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: less
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/peter/npm-debug.log
npm not ok

有没有人知道我该如何解决这个问题?任何细节或帮助将不胜感激。

我已经尝试了这里的一些解决方案,但存在相同的问题,但无济于事。

编辑: 这是 npm-debug.log:

info it worked if it ends with ok
verbose cli [ 'node', '/usr/bin/npm', 'install', '-g', 'less' ]
info using npm@1.1.4
info using node@v0.6.12
verbose config file /home/peter/.npmrc
verbose config file /usr/etc/npmrc
verbose config file /usr/share/npm/npmrc
silly exec /usr/bin/node "/usr/share/npm/bin/npm-get-uid-gid.js" "nobody" 1000
silly spawning [ '/usr/bin/node',
silly spawning   [ '/usr/share/npm/bin/npm-get-uid-gid.js', 'nobody', 1000 ],
silly spawning   null ]
silly output from getuid/gid {"uid":65534,"gid":1000}
silly output from getuid/gid 
verbose cache add [ 'less', null ]
silly cache add: name, spec, args [ undefined, 'less', [ 'less', null ] ]
verbose parsed url { pathname: 'less', path: 'less', href: 'less' }
verbose addNamed [ 'less', '' ]
verbose addNamed [ null, '' ]
silly name, range, hasData [ 'less', '', false ]
verbose raw, before any munging less
verbose url resolving [ 'https://registry.npmjs.org/', './less' ]
verbose url resolved https://registry.npmjs.org/less
http GET https://registry.npmjs.org/less
ERR! Error: failed to fetch from registry: less
ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
ERR!     at Request.emit (events.js:88:20)
ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
ERR!     at ClientRequest.emit (events.js:67:17)
ERR!     at HTTPParser.onIncoming (http.js:1261:11)
ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
ERR! You may report this log at:
ERR!     <http://bugs.debian.org/npm>
ERR! or use
ERR!     reportbug --attach /home/peter/npm-debug.log npm
ERR! 
ERR! System Linux 3.11.0-20-generic
ERR! command "node" "/usr/bin/npm" "install" "-g" "less"
ERR! cwd /home/peter
ERR! node -v v0.6.12
ERR! npm -v 1.1.4
ERR! message failed to fetch from registry: less
verbose exit [ 1, true ]

【问题讨论】:

标签: node.js ubuntu installation less failed-installation


【解决方案1】:

@therefromhere 的回答帮了大忙,我贴在这里:

npm v1.1.4(和node v0.6.12)遇到了这个问题,它们是Ubuntu 12.04 存储库版本。

看起来npm 的那个版本不再受支持,更新节点(和它的 npm)解决了这个问题。

首先,卸载过时的版本(可选,但我认为这解决了我遇到的全局模块未进入路径的问题)。

sudo apt-get purge nodejs npm

然后从 Chris Lea 的仓库安装:

sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

发件人:here

【讨论】:

  • 你可能想记下你最终安装了哪些 npm 和 nodejs 版本。
  • 现在它会给你 v0.10.37
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-24
  • 2015-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
相关资源
最近更新 更多