繁体   English   中英

如何修复 npx create-react-app 错误?

[英]How can I fix npx create-react-app error?

我第一次制作 React 项目时遇到了麻烦,我基本上是在做npx create-react-app portfolio ,这是终端中的日志

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 '...w2l6C\nBZrjaE2TabX86o'
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ITland\AppData\Roaming\npm-cache\_logs\2020-06-13T14_28_52_450Z-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 portfolio/ from C:\Users\ITland\Desktop\New folder (2)

有谁知道是什么导致了这个错误?

上面显示的日志消息表明 npx 命令在文件夹内运行 -

C:\Users\ITland\Desktop\新建文件夹 (2)

由于文件夹名称中的空格或特殊字符,npm 命令有时会在 Windows 上失败。

始终建议在运行 npm 的文件夹名称中避免使用空格和特殊字符。

上面的问题可以通过里面运行npm/npx命令解决

C:\Users\ITland\Desktop\New_folder_2

尝试运行以下命令

npm cache clean --force

一旦成功,请尝试做您正在寻找的事情。

尝试以下方式:

npm cache clean --force

如果您是windows用户,请尝试删除此文件夹中的所有文件:

C:\Users{{您的用户名}}\AppData\Roaming\npm-cache

然后...

npm cache verify

如果这不起作用,请尝试更新到最新版本

npm i npm@latest -g

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM