Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 233
Hakim Bencella Avatar asked May 20 '20 22:05

Hakim Bencella


People also ask

How do I fix unexpected end of JSON input node JS?

You can solve the "Unexpected end of JSON input" error in the following 3 ways: wrap your parsing logic in a try/catch block. make sure to return a valid JSON response from your server. remove the parsing logic from your code if you are expecting an empty server response.


3 Answers

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

like image 131
Abu Darda Avatar answered Oct 21 '22 04:10

Abu Darda


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.

like image 2
Hardik Satasiya Avatar answered Oct 21 '22 04:10

Hardik Satasiya


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 .

like image 1
Vinay Kashyap Avatar answered Oct 21 '22 02:10

Vinay Kashyap