Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't install react using npx create-react-app?

I am trying to use npx create-react app but i have errors that is shown below:

npm ERR! Unexpected end of Json input while parsing near '...eact-app/-/create-rea'  npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\dp\AppData\Roaming\npm-cache\_logs\2018-12-06T18-42-56-293Z-debug.log  Install for create-react-app@latest failed with code 1**  

and the log file of the error is here...!

How I can get rid of this trouble??

0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',  1 verbose cli    'C:\\Users\\dp\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',  1 verbose cli   'install',  1 verbose cli   'create-react-app@latest',  1 verbose cli   '--global',  1 verbose cli   '--prefix',  1 verbose cli   'C:\\Users\\dp\\AppData\\Roaming\\npm-cache\\_npx\\3588',  1 verbose cli   '--loglevel',  1 verbose cli   'error',  1 verbose cli   '--json' ]  2 info using [email protected]  3 info using [email protected]  4 verbose npm-session 7862701600d4f4ce  5 silly install loadCurrentTree  6 silly install readGlobalPackageData  7 http fetch GET 304   https://registry.npmjs.org/create-react-app 872ms (from cache)  8 silly fetchPackageMetaData error for create-react-app@latest Unexpected end of JSON input while parsing near '...eact-app/-/create-rea'  9 timing stage:rollbackFailedOptional Completed in 4ms 10 timing stage:runTopLevelLifecycles Completed in 1693ms 11 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...eact-app/-/create-rea' 11 verbose stack     at JSON.parse (<anonymous>) 11 verbose stack     at parseJson (C:\Users\dp\AppData\Roaming\npm\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17) 11 verbose stack     at consumeBody.call.then.buffer (C:\Users\dp\AppData\Roaming\npm\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50) 11 verbose stack     at process._tickCallback (internal/process/next_tick.js:68:7) 12 verbose cwd C:\Users\dp 13 verbose Windows_NT 6.3.9600 14 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\dp\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "create-react-app@latest" "--global" "--prefix" "C:\\Users\\dp\\AppData\\Roaming\\npm-cache\\_npx\\3588" "--loglevel" "error" "--json" 15 verbose node v10.13.0 16 verbose npm  v6.4.1 17 error Unexpected end of JSON input while parsing near '...eact-app/-/create-rea' 18 verbose exit [ 1, true ] 
like image 695
zanjan_citizen Avatar asked Dec 06 '18 18:12

zanjan_citizen


People also ask

Why can't NPX create react app?

We no longer support global installation of Create React App. The current solution is simple — run create-react-app and target the latest version. Different versions of npm may help as well, and you can upgrade using the following command. Please note that this may affect other projects on your system.

Can't use create react app?

If you really need create-react-app , you might need to reinstall Node and reconfigure your dependencies to ensure you have a fresh start with Node, npm, npx, and the like. This is a good resource for updating and reinstalling Node.


2 Answers

To fix the issue, run these commands in sequence

npm init npm install create-react-app npx create-react-app myapp 
like image 138
Qalib Abbas Avatar answered Sep 16 '22 15:09

Qalib Abbas


I had the same issue "Install for create-react-app@latest failed with code 7" Use this. It worked for me.

npm install -g create-react-app     npx create-react-app my-app      cd my-app       npm start      

for further reference go to: https://www.techomoro.com/how-to-install-and-setup-a-react-app-on-windows-10/

like image 30
Amal K George Avatar answered Sep 19 '22 15:09

Amal K George