繁体   English   中英

无法使用“create-react-app”创建反应应用程序

[英]Unable to create a react app using "create-react-app"

我已经使用“npm install create-react-app -g”在我的电脑上全局安装了“create-react-app”。 它工作了好几个月。 我以前使用“create-react-app app-name”命令创建了很多反应应用程序。 它完美无缺。 直到几天前它突然停止工作并开始出错。 我尝试了各种建议,但没有运气。 所以经过几天的尝试解决这个问题,我问这个问题。

我试过做以下事情:

1> using the "npm cache clean --force" and then "npm cache verify".
2> I also unabled my antivirus (norton) and then ran the commands.
3> I installed the latest node version
4> I intalled the latest npm version and updated it using the command "npm install npm@latest -g"
5> I followed the instructions on this stackoverflow link https://stackoverflow.com/questions/50189096/installing-create-react-app-gives-npm-err-shasum-check-failed-and-npm-err-unex/50191315#50191315 to change the registry.
And a few other things. But nothing has worked.

我得到的错误如下:

D:\codes\react\maximilianUdemy\project1>create-react-app react-mytest-app

Creating a new React app in D:\codes\react\maximilianUdemy\project1\react-mytest-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

npm ERR! Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vaibh\AppData\Roaming\npm-cache\_logs\2019-07-20T10_24_27_969Z-debug.log

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

Deleting generated file... package.json
Deleting react-mytest-app/ from D:\codes\react\maximilianUdemy\project1
Done.

以下是C:\\Users\\vaibh\\AppData\\Roaming\\npm-cache\\_logs\\2019-07-20T10_24_27_969Z-debug.log 由于日志非常大(664 行),我只注意到错误开始显示的时间。

471 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'
471 verbose stack     at JSON.parse (<anonymous>)
471 verbose stack     at parseJson (D:\Program_Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
471 verbose stack     at D:\Program_Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
471 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:85:5)
472 verbose cwd D:\codes\react\maximilianUdemy\project1\react-mytest-app
473 verbose Windows_NT 10.0.17134
474 verbose argv "D:\\Program_Files\\nodejs\\node.exe" "D:\\Program_Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
475 verbose node v12.6.0
476 verbose npm  v6.9.0
477 error Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'
478 verbose exit [ 1, true ]

尝试使用npx create-react-app my-app

我认为此链接中的信息也会对您有所帮助。

这个问题是相对于节点版本的 create-react-app 版本。

创建新项目

npx create-react-app project_name --template all

节点

创建反应应用程序

暂无
暂无

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

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