Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
984 views
in Technique[技术] by (71.8m points)

node.js - Error installing reactjs: Error unexpected end of JSON input while parsing near

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.

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

npm ERR! Unexpected end of JSON input while parsing near '....1","object-hash":"^1'

npm ERR! A complete log of this run can be found in:

npm ERR! C:UsersDavidAppDataRoaming pm-cache_logs2020-02-12T03_53_37_836Z-debug.log

Aborting installation.

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

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 silly saveTree `-- react@16.12.0

204 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '....1","object-hash":"^1'

204 verbose stack at JSON.parse ()

204 verbose stack at parseJson (C:Program Files odejs ode_modules pm ode_modulesjson-parse-better-errorsindex.js:7:17)

204 verbose stack at C:Program Files odejs ode_modules pm ode_modules ode-fetch-npmsrcody.js:96:50

204 verbose stack at processTicksAndRejections (internal/process/task_queues.js:97:5)

205 verbose cwd C:UsersDavidDesktopReactmy-app

206 verbose Windows_NT 10.0.17763

207 verbose argv "C:Program Files odejs ode.exe" "C:Program Files odejs ode_modules pmin pm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts" "cra-template"

208 verbose node v13.8.0

209 verbose npm v6.13.6

210 error Unexpected end of JSON input while parsing near '....1","object-hash":"^1'

211 verbose exit [ 1, true ]

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try running this in your terminal:

npm cache clean --force

And redo the thing you are doing


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...