You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用npx create-react-app创建项目时遇JSON输入意外结束错误求助

Fixing "Unexpected end of JSON input" Error When Creating React App

What's Causing This?

This error almost always pops up because your npm cache has gotten corrupted—either from interrupted downloads, outdated cache files, or garbled data. When npm tries to parse the cached JSON for dependencies like react, react-dom, or react-scripts, it hits a broken file and throws this parsing error.

Step-by-Step Fixes

1. Clear the Corrupted npm Cache

First, let's wipe out the problematic cache entirely. Run this command in your terminal:

npm cache clean --force

This forces npm to discard all cached data, so it’ll download fresh, uncorrupted dependency files next time around.

2. Retry Creating the React App

Now go ahead and try creating your app again:

npx create-react-app starbezz

In most cases, this alone will fix the issue since npm will pull clean, intact copies of the required packages.

3. If the Error Lingers: Update npm

Outdated versions of npm can sometimes cause caching glitches. Update npm to the latest stable release with:

npm install -g npm@latest

Once the update finishes, repeat step 2 to create your app.

4. Alternative: Switch to Yarn (If npm Still Fails)

If npm keeps giving you trouble, you can use Yarn instead. First install Yarn globally:

npm install -g yarn

Then create your React app using Yarn:

yarn create react-app starbezz

Quick Notes

  • The log file you mentioned (C:\Users\HP PC\AppData\Roaming\npm-cache\_logs\2019-04-19T12_24_21_614Z-debug.log) can help you dig deeper if you need more context, but clearing the cache is usually the fastest fix here.
  • Make sure you have a stable internet connection while creating the app—interrupted downloads are a common cause of corrupted cache files.

内容的提问来源于stack exchange,提问作者NETFLEXX joseph

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 05:15:43