create-react-app : npm ERR! Unexpected end of JSON input while parsing near '....'
Asked Answered
S

5

6

Describe the bug

npx create-react-app my-app doesn't work for me i tried npm cache clean --force but i get the same error again and again

Steps to reproduce

  1. npm cache clean --force
  2. npm / npx create-react-app front
npm init react-app front
npx: installed 98 in 37.068s

Creating a new React app in /home/h4kst3r/Desktop/APIs/restaurant-API/front.

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 '...zAJNgZjZUkJ08ybAxwNnR'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/h4kst3r/.npm/_logs/2020-05-20T20_47_49_189Z-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 front/ from /home/h4kst3r/Desktop/APIs/restaurant-API
Done.

System:

OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)

Stalker answered 20/5, 2020 at 22:3 Comment(3)
which npm version you are using ?Almonry
@FarhaniWalid 6.12.0Stalker
try to reinstall them from scratch and see if it will fix the problem, basically the error that you are getting is raised by one of those packages, alternately this may be caused by the permissions that you have, try first sudo npx create-react-app frontAlmonry
B
9

Its happened because of slow internet . So wait till ur internet connection is normal. Or install all dependencies one by one .

Banta answered 9/8, 2020 at 17:51 Comment(2)
Seriously, it's correct answer..... I thought it's wrong actually it's solved the problem.....Affliction
Exactly how fast an Internet connection should be for this error not to happen?Flipflop
I
2

If npx create-react-app my-app command not working and throws an error like: npm ERR! Unexpected end of JSON input while parsing near '...zAJNgZjZUkJ08ybAxwNnR', Just check your npm version:

npm --version 
npm -v

and if required update it:

npm install -g npm@latest

It will definitely work.

Izaguirre answered 17/3, 2021 at 7:55 Comment(0)
I
1

First check for npm version by running the following command npm --version. if you have an npm version then try instally npx globally with the help of npm i -g npx. if npm and ngx are installed properlly then this will work .

Imphal answered 20/5, 2020 at 22:14 Comment(3)
npm npx are both installed!Stalker
sometimes their will be some packages missing thats the reason.Imphal
This helped but I had to also run npm cache clean --force after npm i -g npxDefensible
I
0

sudo npm i -g npx --force worked for me.

Iambic answered 22/11, 2020 at 13:31 Comment(1)
Kindly add descriptive answer so other people can understand it's usage and if possible please add any side effect of command.Martyrdom
P
0

There are probably two things that can be at fault.

  1. Poor internet connection.
  2. outdated npm version.

update your npm and seek a strong internet connection.

Porkpie answered 2/7, 2021 at 13:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.