javascript - 使用 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
解决方案
首先尝试npm cache clean --force
然后再次运行您的命令,这可能会解决您的问题。
这将从缓存文件夹中删除所有可能导致您的错误的数据。
推荐阅读
- python - Tkinter 的超类
- python - Python 从字面上隐藏一行并跳过调用函数
- python - 最后一位以 5 舍入小数点
- dns - 将 example.com 重定向到 www.example.com
- apache - 强制将 HTTPS 与 .COM 域和 .htaccess 中的 WWW 一起使用
- javascript - Webdriverio(独立) - 为元素分配一个变量允许我运行 webdriver 函数。为什么?
- sql-server - 如何使用 SSMA(用于访问 SQL Server)将具有不同列的表迁移到现有表中?
- node.js - 如何在 Mongoose 中保存包含数组的表单数据?
- sql-server - 我可以在我的 db 表中自动递增外键列,使其与 SQL Server 中主表的自动递增主键列匹配吗?
- git - 当按q退出git log时,日志退出成功,但在下一个提示后还会打印“q”