安装reactjs时出错:解析附近时,JSON输入意外结束错误 [英] Error installing reactjs: Error unexpected end of JSON input while parsing near
问题描述
我尝试使用1)npx create-react-app my-app
和2)npx create-react-app app
I tried installing reactjs via node using two different commands in the terminal using 1) npx create-react-app my-app
and 2) npx create-react-app app
但是两者都产生了如下所示的相同错误:
But both yielded the same error shown below:
安装软件包.这可能需要几分钟.
Installing packages. This might take a couple of minutes.
使用cra-template安装react,react-dom和react-scripts ...
Installing react, react-dom, and react-scripts with cra-template...
npm ERR!解析附近时JSON输入意外结束 '.... 1,"对象哈希:" ^ 1'
npm ERR! Unexpected end of JSON input while parsing near '....1","object-hash":"^1'
npm ERR!可以在以下位置找到此运行的完整日志:
npm ERR! A complete log of this run can be found in:
npm ERR! C:\ Users \ David \ AppData \ Roaming \ npm-cache_logs \ 2020-02-12T03_53_37_836Z-debug.log
npm ERR! C:\Users\David\AppData\Roaming\npm-cache_logs\2020-02-12T03_53_37_836Z-debug.log
中止安装.
npm install --save --save-exact --loglevel错误反应react-dom react-scripts cra-template失败.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
我尝试卸载并重新安装节点,还尝试安装不同版本的reactjs,但仍然遇到相同的错误.另外,我尝试清除节点缓存,然后再次通过npm cache clear --force
和npm cache verify
对其进行验证,但是仍然没有任何运气.任何帮助将不胜感激.
I tried uninstalling and reinstalling node and also trying to install different older versions of reactjs but still got the same error. Also, I have tried clearing the node cache and then verifying it again via npm cache clear --force
and then npm cache verify
but still have not had any luck. Any help will be greatly appreciated.
更详细的日志显示在底部:
The more detailed log shows this at the bottom:
203愚蠢的saveTree`-react@16.12.0
203 silly saveTree `-- react@16.12.0
204详细堆栈SyntaxError:时JSON输入意外结束 在'.... 1," object-hash:" ^ 1'
204 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '....1","object-hash":"^1'
JSON.parse()处的204详细堆栈
204 verbose stack at JSON.parse ()
parseJson的204详细堆栈(C:\ Program 文件\ nodejs \ node_modules \ npm \ node_modules \ json-parse-better-errors \ index.js:7:17)
204 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
C:\ Program中的204详细堆栈 文件\ nodejs \ node_modules \ npm \ node_modules \ node-fetch-npm \ src \ body.js:96:50
204 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
processTicksAndRejections上的204详细堆栈 (internal/process/task_queues.js:97:5)
204 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)
205详细的CWD C:\ Users \ David \ Desktop \ React \ my-app
205 verbose cwd C:\Users\David\Desktop\React\my-app
206详细的Windows_NT 10.0.17763
206 verbose Windows_NT 10.0.17763
207详细argv"C:\ Program Files \ nodejs \ node.exe""C:\ Program Files \ nodejs \ node_modules \ npm \ bin \ npm-cli.js"安装"-保存 "--save-exact""--loglevel"错误""react""react-dom" 反应脚本","cra-模板"
207 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts" "cra-template"
208个详细节点v13.8.0
208 verbose node v13.8.0
209详细的npm v6.13.6
209 verbose npm v6.13.6
210错误,在解析附近时JSON输入意外结束 '.... 1,"对象哈希:" ^ 1'
210 error Unexpected end of JSON input while parsing near '....1","object-hash":"^1'
211详细出口[1,true]
211 verbose exit [ 1, true ]
推荐答案
使用节点包管理器安装yarn为我解决了该问题.打开命令提示符,然后输入:
Installing yarn using node package manager fixed the issue for me. Open command prompt and enter:
npm install -g yarn
这篇关于安装reactjs时出错:解析附近时,JSON输入意外结束错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!