DEV Community

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

npm ERR! Unexpected end of JSON input while parsing near

Rishi on May 15, 2020

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...
Collapse
 
thealjey profile image
Eugene Kuzmenko • Edited

It doesn't help. It's dumb to suggest for people to clean their cache every time.
The --force flag is there for a reason. It's giving you the option, while at the same time trying to persuade you not to do it.
What I wish is for some of these articles to suggest a way to identify the failing package.
Because the npm error logs are less than useless in this regard.
It needs to print the url it was trying to fetch, and not just say that it failed to parse some abstract json, coming from God only knows where.
On any decently sized project there are hundreds of packages.
Many companies use proxy servers for npm.
An attempt to load a package can fail for a multitude of reasons.

Collapse
 
davidakinjames profile image
Akinwande Akin-James

So what do you sugggest?

Collapse
 
thealjey profile image
Eugene Kuzmenko

I am, honestly, yet to find a good solution for this.
The problem is not so much with this article as it is with npm itself.
Just use yarn if you can 😀

Thread Thread
 
davidakinjames profile image
Akinwande Akin-James • Edited

Its all good

Collapse
 
anproghub profile image
Ankush Chauhan • Edited

first run

npm i -g create-react-app

image1
then it will update and remove some package in this directly to




**Then your can easily run**

 ```npx create-react-app my-app```



and it will works !!!!!
Enter fullscreen mode Exit fullscreen mode
Collapse
 
rishiabee profile image
Rishi

Nice!!! Thanks Ankush.

Collapse
 
dmakuto profile image
Derick Makuto Simiyu

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!

Collapse
 
ronnielutalo profile image
Ronnie Lutalo

Hello! this has worked for me too. Thanks!

Collapse
 
rishiabee profile image
Rishi

Nice!!!

Collapse
 
madhusudanbabar profile image
Krypton | Madhusudan Babar

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

Collapse
 
rishiabee profile image
Rishi • Edited

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 :-)

Collapse
 
madhusudanbabar profile image
Krypton | Madhusudan Babar

Yeah,
I already switched to yarn
Thanks 😇

Thread Thread
 
rishiabee profile image
Rishi

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

Thread Thread
 
arrefl profile image
Ariel Reyes

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

Thread Thread
 
arrefl profile image
Ariel Reyes

Ahhh Sorry. Thnks it worked.

Collapse
 
stasdomanskyi profile image
Stanislav Domanskyi

Thank you! I had the same issue with executing npm i -g @loopback/cli

It has helped me but first I switched through the nvm from node v12.19.0 to 10.22.1
After following all above instructions finally I've got this package.

Collapse
 
russelsantos19 profile image
Russel Santos

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.

Collapse
 
incubers31 profile image
incubers31

E:\xampp\htdocs\sumit\angular>npm install -g @angular/cli
npm ERR! Response timeout while trying to fetch registry.npmjs.org/@schematics%2fa... (over 30000ms)

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sam\AppData\Roaming\npm-cache_logs\2020-07-20T06_40_14_633Z-debug.log

Please tell me why this issue occurring during installing Angular

Collapse
 
binel01 profile image
Binel binel

This really helped me. I was facing that issue when trying to create a new Angular project and an ionic project. After cleaning my NPM cache, I successfully installed the ionic app.

Thank you very much.

Collapse
 
ollyimanishimwe profile image
Olly

Thanks!
it worked smothly.

Collapse
 
abrahamhassan08 profile image
Abraham Hassan

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

Collapse
 
rishiabee profile image
Rishi

Glad it helped!

Collapse
 
infortraining profile image
infortraining

Resolveu meu problema, muito obrigado!

Collapse
 
pradip_nalwaya profile image
Pradip Nalwaya

Hey Rishi, Thanks for it.
After Cashe and Delete All data from \AppData\Roaming\npm-cache. Then Updates npm with Latest Version. and Install Cordova . now it's done. Working Fine, Now All.

Collapse
 
_andwati profile image
Ian Andwati

Thanks alot. I had issues installing gulp-cli, this solution fixed it

Collapse
 
habimanasharif profile image
habimanasharif

i had also struggled with this error and this and i have solved this error by using running the command npm install in an adminstrator terminal and it worked on ubuntu os

Collapse
 
moojob profile image
Moojob

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

Collapse
 
curlylazy profile image
Curly Lazy

thanksss dude... a lott.....

Collapse
 
doublejointed profile image
doublejointed

@rishiabee - thank you!!!

I joined DEV just so I could post this. Lifesaver.

Collapse
 
react_dev_gani profile image
React_dev_Gani

im facing 8 hours now i got resolved your steps really help me thanks lot Rishi sir

Collapse
 
robinkartikeyakhatri profile image
Robin Kartikeya Khatri

Thanks a lot 👍🙏

Collapse
 
philme1 profile image
Philme1

Thanks so much Rishi, I have been battling this for weeks now, your solution worked for me

Collapse
 
drozerah profile image
Drozerah

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

Collapse
 
rishiabee profile image
Rishi

Fantastic ;)

Collapse
 
bbalaji64616464 profile image
B balaji

This helps

Collapse
 
davidakinjames profile image
Akinwande Akin-James

I use Angular and I don't see solutions for it. Please help me

Collapse
 
alicankal profile image
Cankal Software

Thank you, al work like Hero. I did not know so much cache for npm. thanks.

Collapse
 
masud309060 profile image
Md Masud Rana

It's working. Thanks, a lot for this easy way to solve this problem. May Allah bless you brother.

Collapse
 
zacharydinerstein profile image
Zachary Dinerstein

I'm on windows. Clearing my cache and then deleting files in the folder above worked for me. Thanks!

Collapse
 
brdionel profile image
Bruno Dionel Vicente

It was the only thing that worked.
Thanks.

Collapse
 
davidolawale profile image
David Olawale

Thanks, it works

Collapse
 
akhi1 profile image
Akhil

Sorted out my "workflow error" issue thanks @rishi

Collapse
 
rishiabee profile image
Rishi

Nice! ;-)

Collapse
 
njezeoj profile image
NjezeOj

Worked for me thanks

Collapse
 
joshtom profile image
Joshua Olajide

This Article just got a 2-day error fixed. Please don't stop writing! :)