3
votes

I made some changes to the npm configuration in the previous days, and now I consistently receive the same error while trying to install any of a variety of packages. Essentially, I cannot utilize npm anymore due to what I think is a personal erroneous change to npm settings.

I have uninstalled node and npm, and re-installed, and tried the configuration settings in the npm blog, and I still get the same error. Perhaps it has to do with permissions in Cellar directory? I thought I had taken care of that previously...

It is not clear to me what is the issue and would appreciate your help very much.

Error output is below:

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!     

The output of npm config list generates:

$ 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

1 Answers

3
votes

If you open file /usr/local/Cellar/node/0.10.26/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js, and insert console.log(data) on the line 202 (just before JSON.parse, you will be able to see what error are you getting.

You can also get the npm configuration using npm config list and post it, or just remove your npmrc file. But I'm not sure it's a configuration issue.

Also, it's strange that you make a request over HTTP, since default URL is HTTPS. Maybe some firewall is screwing things up(?).