3

I have installed "create-react-app" globally on my pc using "npm install create-react-app -g". And it worked just fine for months. I had previously created a lot of react app using the "create-react-app app-name" command. And it worked flawlessly. Until a few days ago when it sudden stopped working and started giving errors. I have tried various things suggested but with no luck. So after days of trying to solve the issue I am asking this question.

I have tried doing the following things:

1> using the "npm cache clean --force" and then "npm cache verify".
2> I also unabled my antivirus (norton) and then ran the commands.
3> I installed the latest node version
4> I intalled the latest npm version and updated it using the command "npm install npm@latest -g"
5> I followed the instructions on this stackoverflow link https://stackoverflow.com/questions/50189096/installing-create-react-app-gives-npm-err-shasum-check-failed-and-npm-err-unex/50191315#50191315 to change the registry.
And a few other things. But nothing has worked.

The error that I get is as follows:

D:\codes\react\maximilianUdemy\project1>create-react-app react-mytest-app

Creating a new React app in D:\codes\react\maximilianUdemy\project1\react-mytest-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

npm ERR! Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\vaibh\AppData\Roaming\npm-cache\_logs\2019-07-20T10_24_27_969Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

Deleting generated file... package.json
Deleting react-mytest-app/ from D:\codes\react\maximilianUdemy\project1
Done.

Below is an excerpt from the C:\Users\vaibh\AppData\Roaming\npm-cache\_logs\2019-07-20T10_24_27_969Z-debug.log. Since the log is really big (664 lines), I have only noted from when the error started showing.

471 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'
471 verbose stack     at JSON.parse (<anonymous>)
471 verbose stack     at parseJson (D:\Program_Files\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
471 verbose stack     at D:\Program_Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
471 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:85:5)
472 verbose cwd D:\codes\react\maximilianUdemy\project1\react-mytest-app
473 verbose Windows_NT 10.0.17134
474 verbose argv "D:\\Program_Files\\nodejs\\node.exe" "D:\\Program_Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "--loglevel" "error" "react" "react-dom" "react-scripts"
475 verbose node v12.6.0
476 verbose npm  v6.9.0
477 error Unexpected end of JSON input while parsing near '...HqQqP7Ky/f49Ar0oPZ\n4'
478 verbose exit [ 1, true ]
9
  • Try this npx create-react-app react-mytest-app Commented Jul 20, 2019 at 12:43
  • try uninstall and reinstall using npm uninstall -g create-react-app Commented Jul 20, 2019 at 12:51
  • @ravibagul91 I tried that too. It also gives the same error Commented Jul 20, 2019 at 13:14
  • @Sushilzzz I had previously updated npm but it didn't work. I uninstalled and reinstalled as you said, but it still gives the same error. Commented Jul 20, 2019 at 13:15
  • try deleting everything under C:\Users\<yourUser>\AppData\Roaming\npm-cache Commented Jul 20, 2019 at 14:07

3 Answers 3

1

Try to use npx create-react-app my-app

I think also information in this link will help you.

Sign up to request clarification or add additional context in comments.

1 Comment

what's the problem statement? What have you tried already? What error messages appeared when trying to run said command?
0

This problem is create-react-app version with respect to node version.

Create new project

npx create-react-app project_name --template all

Node

create-react-app

Comments

0

First use npx create-react-app, but if the problem persists ->

This will happen usually due to 1 of the two reasons :

  1. Your npm registry is messed up somehow.
  2. You have an old version of 'create-react-app'.

To solve this try:

  1. Run npm get registry to see your current, and npm set registry https://registry.npmjs.org/ to set the registry to default.
  2. To get the new version of create-react-app, simply uninstall the old one globally through npm uninstall -g create-react-app and then run npx create-react-app for creating your react app.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.