npm error when install react project in create-react-app - reactjs

Hi thanks for reading this topic
I work with react I nowadays trying to learn ReactJS when install react new app show an error for uninstall react new project
what is my problem
in Command Terminal
npm ERR! Unexpected end of JSON input while parsing near
'...9.1","tslint-config
-p'
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\john\AppData\Roaming\npm-cache_logs\2019-12-26T01_36_25_1
39Z-debug.log npm install --save #testing-library/react#^9.3.2
#testing-library/jest-dom#^4.2 .4 #testing-library/user-event#^7.1.2
failed

I think it's version problem.
If you've previously installed create-react-app globally via npm install -g create-react-app, we recommend you uninstall the package using npm uninstall -g create-react-app to ensure that npx always uses the latest version
Quick Start
npx create-react-app my-app
cd my-app
npm start
For more clarification check this reactjs

I faced the same problem quite a few times.
Then used following commands, it worked for me
npm init
npm cache clean force
npx create-react-app my-app
cd my-app
npm start

Related

create-react-app not working. Getting error "Module not found"

This is what I'm getting
I am not able to create a project using create-react-app, I get the error "Module not found".
Node version is 17.0.1 and Npm version is 8.1.1
I have reinstalled nodejs 3 times now and have tried different commands like
npm install create-react-app -g
npm cache clean --force
P.S - I have updated the nodejs to 17.0.1 as the picture version shows 16.13.0
You can try with npx create-react-app my-app.
Visit for more details create-react-app
To create a new app, you may choose one of the following methods:
npx
npx create-react-app my-app
npm
npm init react-app my-app
npm init <initializer> is available in npm 6+
Yarn
yarn create react-app my-app
yarn create is available in Yarn 0.25+
So after almost 3-4 hours of trying different things, it has worked.
I dont know which particular thing would have helped it to work but following are the things I tried -
Delete npm and npm cache folder.
Reinstall the nodejs (LTS version).
Create the app in another folder.
Used power shell instead of CMD.
npm fix
npm fix --force

While creating a react app I'm getting following error or errors

I ran create-react-app and get this error message I did the followings like uninstalling global and so no but getting the same again and again.
You are running `create-react-app` 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
npm ERR! code 1
npm ERR! path J:\Akhlak_hossain_jim
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c ""create-react-app" "ahj-app" "--use-npm""
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Akhlak Hossain Jim\AppData\Local\npm-cache\_logs\2020-11-24T15_16_27_423Z-debug.log
Edit:
I've also tried the following:
Using npx instead. - but that's not working and is showing the above error message.
Uninstalled create-react-app using npm uninstall -g create-react-app before running npx create-react-app ahj-app - however that also doesn't work.
npm install -g create-react-app
Above worked for me.
Do not use npm to install "create-react-app" instead use npx this way:
npx create-react-app my-app
it will always use the lastest version
I solved this using the following command.
npm uninstall -g create-react-app
then again install
npm install -g create-react-app
PS D:\ReactProjects> npx create-react-app sample-app
Creating a new React app in D:\ReactProjects\sample-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npx create-react-app#5.0.0 ahj-app
Specify the latest version explicitly when creating new app

Create react app is not working correctly

D:\React>create-react-app secondapp
Creating a new React app in D:\React\secondapp.
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 '...2.2","is-glob":"^4.0.'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Divyansh Chaudhary\AppData\Roaming\npm-cache\_logs\2020-08-26T08_41_16_573Z-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 secondapp/ from D:\React
Done.
D:\React>
Try:
npx create-react-app Secondapp
With the newer versions of npm (version 5.2 and higher), you are recommended to use npx to use create-react-app instead. According to the create-react-app github, you are advised to
uninstall create-react-app:
npm uninstall -g create-react-app
clear and verify cache
npm cache verify
create a react app with npx and start it like
npx create-react-app my-app
cd my-app
npm start

Why create-react-app doesn't create new app

I installed the latest version on Node JS with npm and cannot run create-react-app.
The following problem occurs:
Creating a new React app in C:\wamp64\www\bob.
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 '....tgz"}},"2.3.4":{"nam'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2019-02-26T21_21_48_727Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\wamp64\www
Done.
Versions:
Node v10.15.1
npm 6.7.0
Can somebody help?
After running npm cache clean --force
the another error occurs:
$ create-react-app bob
Creating a new React app in C:\Users\Ivana\bob.
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 '...,"#babel/plugin-synta'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache\_logs\2019-02-27T09_18_28_856Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\Users\Ivana
Done.
From https://create-react-app.dev/docs/getting-started#creating-an-app
npx create-react-app my-app
(npx comes with npm 5.2+ and higher)
But you used
`create-react-app my-app`
If you use npm 5.1 or earlier, you can't use npx. Instead, install create-react-app globally:
npm install -g create-react-app
Now you can run:
create-react-app my-app
I was also not able to create a new app but when I follow these step
then it works for me.
After a few searches, I found this :
If you've previously installed create-react-app globally via npm install -g
create-react-app, we recommend you uninstall the package using npm uninstall -g
create-react-app to ensure that npx always uses the latest version.
So if you installed create-react-app with
npm -g install create-react-app
just run :
npm -g uninstall create-react-app
npx create-react-app
It should do the job
I was able to solve this problem by,
running
npm cache clean --force
then
npm create-react-app my-app

NPM error E404 when try to start create-react-app and installing react-dev-utils

I got error when run command create-react-app react-app...
npm ERR! code E404
npm ERR! 404 Not Found: react-dev-utils#https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-5.0.2.tgz
node version: 8.11.4
npm version: 5.6.0
please help
Try to install below first globally and the run the react create cmd
step 1: npm install -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz
step 2: npx create-react-app my-app
your application will up and running.
(remove the "/-/" from the URL) and run the command below
npm install -g react-dev-utils#https://registry.npmjs.org/react-dev-utils/react-dev-utils-5.0.2.tgz
Then try to run again
create-react-app react-app
on windows os, uninstall node completely then install the latest one again. I solved my issue like that and works like a charm..

Resources