npm install SyntaxError:意外的令牌C.

时间:2014-03-07 21:57:35

标签: javascript node.js npm homebrew

我在前几天对npm配置进行了一些更改,现在我在尝试安装任何各种软件包时始终收到同样的错误。基本上,由于我认为对npm设置的个人错误更改,我不能再使用npm了。

我已经卸载了node和npm,并重新安装了,并尝试了npm博客中的配置设置,但仍然得到了同样的错误。也许它与Cellar目录中的权限有关?我以为我以前照过这个......

我不清楚问题是什么,非常感谢你的帮助。谢谢。错误输出粘贴在下面:

npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token C
npm ERR! Cannot GET http://registry.npmjs.org/node-simple-router
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient. (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:203:23)
npm ERR!     at Request.self.callback (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/request/request.js:123:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request. (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/request/request.js:893:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR!     at IncomingMessage. (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/request/request.js:844:12)
npm ERR!     at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR!     at _stream_readable.js:920:16
npm ERR!     at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     

npm config list的输出生成:

$ npm config list
; cli configs
registry = "http://registry.npmjs.org/"

; userconfig /Users/rfatahi/.npmrc
ca = ""
https-proxy = "http://127.0.0.1:8888/"
proxy = "http://127.0.0.1:8888/"
registry = "http://registry.npmjs.org/"
strict-ssl = true

; builtin config undefined
prefix = "/usr/local"

; node bin location = /usr/local/Cellar/node/0.10.26/bin/node

1 个答案:

答案 0 :(得分:3)

如果您打开文件/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js,并在第202行(就在console.log(data)之前)插入JSON.parse,您就可以看到有什么错误。

您也可以使用npm config list获取npm配置并发布,或者只删除您的npmrc。但我不确定它的配置问题。

此外,您通过HTTP发出请求很奇怪,因为默认网址是HTTPS。也许有些防火墙搞砸了?