loading...
Cover image for npm ERR! Unexpected end of JSON input while parsing near

npm ERR! Unexpected end of JSON input while parsing near

rishiabee profile image Rishi ・1 min read

You are trying to create a new angular, react, vue app, and you end up with an error message saying:

npm ERR! Unexpected end of JSON input while parsing near

Alt Text

There's a high chance that your npm cache been damaged.

Try:

npm cache clean --force

If you are a windows user, try deleting all files in this folder:

C:\Users{{your-username}}\AppData\Roaming\npm-cache

Then...

npm cache verify

If that doesn't work, try updating to the lastest (understand the risks)

npm i npm@latest -g

I hope this helps!

Posted on May 15 by:

rishiabee profile

Rishi

@rishiabee

Computer Science is evolving so fast... I'm eternally a student. Here're some of my notes.

Discussion

markdown guide
 

But i get this error for every single installation,
I tried with --cache to temporarily set another cache directory but still,
It happens everytime with me

 

Normally,
npm cache clean --force
solves the problem for most people.

If you scenario permits, you can consider a full uninstall of npm + delete the C:\Users{{your-username}}\AppData\Roaming\npm-cache folder.

Then re-install npm.

Finally, if nothing works for you, give yarnpkg.com/ a try.
You'll find yarn faster than npm :-)

 

Yeah,
I already switched to yarn
Thanks 😇

Nice!!!
Always have a plan B :-)

How can I really switch to Yarn and avoid PACKAGE.JSON MIXING?

Ahhh Sorry. Thnks it worked.

 

Unexpected end of JSON input while parsing near '...13G5T8C+0g+Ie\nFKMevH'
I'm a windows user n got the above error while running create-react-app on my terminal.
After deleting everything in npm-cache, then ran npm cache verify, the create-react-app command installed...
Thanks!

 
 

I had the same problem but npm cache clean --force didn't work for me. What I did was CLEAN MY PC using my cleaner(CCleaner) and npm install work now. I did it because the problem appears after I uninstall my node.js because I want to install nvm-windows on my PC (docs.microsoft.com/en-us/windows/n...), but after I did it I think some files and folders was leave behind making a conflict after I install node using nvm thus npm install do not work. So I thought cleaning my pc would solve the problem and it did.
These are just my thoughts. Hope to help someone.

 

Resolveu meu problema, muito obrigado!

 
 

Facing the same issue, I ended up with your solution and it work ! Thank you Rishi !

 
 

Rishi, thank you so much for the instructions! This fixed the error.

 
 
 

Sorted out my "workflow error" issue thanks @rishi