Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM Error Parsing Json, Unexpected Token

Tags:

json

node.js

npm

I'm trying to install grunt, but no luck.

npm install -g grunt-cli --registry http://registry.npmjs.org/

gives this error:

npm ERR! registry error parsing json
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "grunt-cli" "--registry" "http://registry.npmjs.org/"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1
npm ERR! Unexpected token <
npm ERR! <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
npm ERR! <html><head>
npm ERR! <title>404 Not Found</title>
npm ERR! </head><body>
npm ERR! <h1>Not Found</h1>
npm ERR! <p>The requested URL /grunt-cli was not found on this server.</p>
npm ERR! </body></html>

What could be wrong?

like image 615
Jaeeun lee Avatar asked Jun 12 '15 19:06

Jaeeun lee


People also ask

How do I fix unexpected token in JSON error?

The "Unexpected token u in JSON at position 0" error occurs when we pass an undefined value to the JSON. parse or $. parseJSON methods. To solve the error, inspect the value you're trying to parse and make sure it's a valid JSON string before parsing it.

What is unexpected token E in JSON at position 0?

Re: Unexpected token in JSON at position 0 This usually means that an error has been returned and that's not valid JSON. Check the browser developer tools console and network tabs. Turn on Debugging and (after reproducing the error) check the web server error logs.


2 Answers

I just ran the command,

first:

$ rm -f package-lock.json

after:

$ npm i

work for me ;)

like image 103
rflmyk Avatar answered Dec 15 '22 01:12

rflmyk


This did it for me, although not sure why.

npm config rm proxy
npm config rm https-proxy

http://jonathanblog2000.blogspot.ch/2013/11/set-and-reset-proxy-for-git-and-npm.html

like image 37
Jaeeun lee Avatar answered Dec 15 '22 00:12

Jaeeun lee