Nilesh
Nilesh

Reputation: 59

npm ERR! Unexpected end of JSON input while parsing near '...npmjs.org/prelude-ls/'

Trying to run:

npm install @angular-devkit/build-angular

Getting below while installing

npm ERR! Unexpected end of JSON input while parsing near '...npmjs.org/prelude-ls/'

Please help

Upvotes: 5

Views: 920

Answers (3)

zagabo
zagabo

Reputation: 1

If you are using IntelliJ and are on a Mac and connecting through a VPN - I kept getting "Unexpected end of JSON input while parsing near..." when running npm install.

I had a look here:- NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'

I tried

  1. deleting the package-lock.json
  2. sudo npm cache verify
  3. sudo npm cache clean --force
  4. sudo npm update
  5. sudo rm -rf node_modules
  6. sudo npm install --force
  7. Deleting the repo and starting from scratch

I was trying all these commands inside the IntelliJ embedded terminal emulator. I tried npm install on a Mac bash terminal and it worked okay. So it seems like even though both are using the default bash shell, the IntelliJ terminal adds some extra overhead and when connecting through an office VPN it seems to time out.

Upvotes: -1

Fasrin Aleem
Fasrin Aleem

Reputation: 1

I got the same proplem. Try with below command. It's worked for me.

**npm cache clean --force**

Or else you can try removing all the files that were listed below problem will solve.

> For Windows : go to C:\Users\username\AppData\Roaming\npm-cache 
> Delete all files and install angular again.

Upvotes: 0

Abbas Siddiqi
Abbas Siddiqi

Reputation: 391

Cleaning the corrupted local npm cache may fix this error.

npm cache clean --force

Just run your npm command again after executing the above command in your terminal.


There could be few other reasons for the invalid JSON, as described in the official documentation here.

The official npm website has well documented most of the common errors. But unfortunately they don’t appear on the top results when you google the error.

Upvotes: 6

Related Questions