首页 > 解决方案 > 使用 Create-React-App 创建 React 应用程序失败并出现 ERR!在'...er":"^2.0.0","eslint"' 附近解析时 JSON 输入意外结束

问题描述

我使用以下命令使用 Create-React-App 工具创建了一个 React 应用程序:

C:\Users\Valdo\Desktop\Test\React>npx create-react-app my-app

但是我遇到了一个错误,这是我的终端日志:

Creating a new React app in C:\Users\Valdo\Desktop\Test\React\my-app.

Installing packages.
This might take a couple of minutes.

Installing react, react-dom, and react-scripts with cra-template...

npm ERR! Unexpected end of JSON input while parsing near '...fdd1679ff","tarball":'

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Valdo\AppData\Roaming\npm-cache_logs\2020-04-23T16_44_10_449Z-debug.log

Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting my-app/ from C:\Users\Valdo\Desktop\Test\React

标签: javascriptreactjs

解决方案


首先尝试npm cache clean --force然后再次运行您的命令,这可能会解决您的问题。

这将从缓存文件夹中删除所有可能导致您的错误的数据。


推荐阅读