I’m trying to set up a new React project but keep running into this frustrating error. Here are my system details:
Node.js version: 8.9.2
NPM version: 5.5.1
I’m running this command:
npm install -g create-react-app
But I keep getting this error message:
npm ERR! Unexpected end of JSON input while parsing near '...extract-text-webpack-plugin":"1'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Developer\AppData\Roaming\npm-cache\_logs\2017-12-06T14_25_33_482Z-debug.log
I’ve tried clearing the npm cache and restarting my terminal but nothing seems to work. Has anyone encountered this before? What could be causing this JSON parsing issue during the installation process?
Your npm config’s probably pointing to a corrupted or slow mirror. I hit this exact error when my corporate proxy was messing with JSON responses from the registry. Run npm config list to check for weird proxy settings or registry mirrors. Antivirus software can also mess with npm downloads - it’ll truncate JSON files while they’re downloading. I fixed it by temporarily turning off real-time protection during install. That webpack plugin reference in your error shows the download got cut off halfway through the package metadata, so it’s definitely network interference, not just cache issues.
That JSON parsing error sucks, but you can skip the whole installation mess.
Don’t waste time fighting npm cache corruption and Node version conflicts. Just automate your React setup instead. I deal with this crap daily at work and manual troubleshooting eats up way too much time.
Build a workflow that grabs the latest create-react-app template, installs everything, and sets up your project structure automatically. Throw in your custom boilerplate, environment variables, and dev tools while you’re at it.
No more broken npm installs. Reuse the same setup for every project. I automated our entire React onboarding and it saves hours weekly.
The automation handles version conflicts and cache issues behind the scenes. Way cleaner than manually fixing npm every damn time.
i faced that issue too on win. just delete your package-lock.json and try npm install again. that lock file gets corrupt sometimes, which can mess up the JSON. also make sure you got enough disk space, it can cause this error too.
That JSON parsing error usually means your npm cache got corrupted or the registry response is broken. You’ve already cleared the cache, so try npm cache clean --force then npm cache verify. Still broken? Switch registries with npm install -g create-react-app --registry https://registry.npmjs.org/. I had the same issue when my internet kept cutting out and downloads got incomplete. Manually deleting everything in the npm cache directory fixed it for me.
Node 8.9.2 is ancient - that’s definitely what’s breaking your npm packages. I hit the same JSON parsing errors when I was stuck on old Node versions. The package metadata format changed, and create-react-app’s webpack dependencies need newer Node features that just don’t exist in v8. Upgrade to Node 14+ and you’ll fix this instantly - same thing happened to me last year. Grab the latest LTS from the Node.js site. Once you upgrade, you won’t need to clear cache or switch registries because the parsing will actually work.