failed to fetch from registry: formidable
发布于 10 年前 作者 gaoguoxin 8721 次浏览 最后一次编辑是 8 年前

如题,系统为ubuntu 12.04 在安装 formidable的时候报以上错误,以下是我的本地环境

npm ERR! System Linux 3.2.0-38-generic
npm ERR! command "node" "/usr/bin/npm" "install" "formidable"
npm ERR! cwd /home/naitnix/workspace/NodePro/firstPro
npm ERR! node -v v0.6.15
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: formidable
nmp list
# => empty

npm config get proxy
# => null

npm config get registry
# => http://registry.npmjs.vitecho.com/

网上大致搜索了下,说是registry 不稳定造成的,也尝试了很多其他的registry,但是都是同样的错误,不知道大家在这里是怎么解决的

5 回复

刚刚升级了下node和npm: npm ERR! System Linux 3.2.0-38-generic npm ERR! cwd /home/naitnix npm ERR! node -v v0.11.10 npm ERR! npm -v 1.3.22

npm config get proxy
# => null

npm config get registry
# => http://cnpmjs.org/

之后执行命令: npm install formidable 会报错: **npm ERR! SyntaxError: Unexpected token < **

npm http GET http://cnpmjs.org/formidable
npm http 200 http://cnpmjs.org/formidable
npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token <
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient.<anonymous> (/home/naitnix/.nvm/v0.11.10/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:241:23)
npm ERR!     at Request.self.callback (/home/naitnix/.nvm/v0.11.10/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR!     at Request.EventEmitter.emit (events.js:104:17)
npm ERR!     at Request.<anonymous> (/home/naitnix/.nvm/v0.11.10/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR!     at Request.EventEmitter.emit (events.js:123:20)
npm ERR!     at IncomingMessage.<anonymous> (/home/naitnix/.nvm/v0.11.10/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:123:20)
npm ERR!     at _stream_readable.js:896:16
npm ERR!     at process._tickCallback (node.js:599:11)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/isaacs/npm/issues>

问题解决了,在我升级了node和npm后,如上所示,这个时候设置 registry为 http://cnpmjs.org 就会报错,无奈的情况下又设置回了http://registry.npmjs.org 之后再次install 之后,问题就解决了,不知道是不是因为中国的registry问题。

楼主,你看到cnpmjs.org ,看看页面里面说的描述,或者使用淘宝 npm.taobao.org,真正的registry 地址是 registry.npm.taobao.org

谢谢!

回到顶部