'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 ]
Solution 1:[1]
To fix the issue, run these commands in sequence
npm init
npm install create-react-app
npx create-react-app myapp
Solution 2:[2]
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/
Solution 3:[3]
Clean npm cache:
npm cache clean --force
then try again
Solution 4:[4]
First, clear cache by typing this in your terminal:
npm cache clean --force
Then upgrade your version of npm by either following these steps or type:
npm install -g npm@next
Now go to "NodeJS" in Programs and Features in your Windows settings and Repair your installation.
Restart terminal and type:
npx create-react-app my-app
This should hopefully fix your issue.
Solution 5:[5]
I had the same problem in creating react project when I used commands from official source https://reactjs.org/docs/create-a-new-react-app.html#create-react-app
npx create-react-app my-app
cd my-app
npm start
The above commands din't work on my windows. I have Node >= 6 and npm >= 5.2 on my machine even then it is not able to open localhost:3000 then I used this commands
npm install -g create-react-app
create-react-app my-app-name
cd my-app-name
npm start
It worked perfectly fine. I learned from https://www.youtube.com/watch?v=pCgDRgmfilE
Solution 6:[6]
This worked for me!!
first you need to create the package.json file by
npm init
then
npx create-react-app myapp
Solution 7:[7]
Sometime it happens because of slow internet speed. Try with this one.
npx create-react-app <app name> -timeout=60000
Default timeout=30000(30sec). increase timeout, if you necessary.
Solution 8:[8]
The problem arises due to so many reasons.
-
- This happens is if one of the node modules requires to install your react app is missing.
-
- The other reason is if your have and unstable network connection.
-
- Sometimes, but on rare cases, your antivirus may assume the cmd files in your cache to be malware.
if your antivirus is your issue, disable it for the period you run the commands.
Whatever the reason for npx create-react-app is not working on your machine, run the following commands in sequence:
npm cache clean --force
npx create-react-app my-app
let me know if this worked for you
Solution 9:[9]
In your antivirus whitelist the node software
hey guys in my point of view, check your system any antivirus is running and blocking the node.exe more specifically (ByteFence Anti-malware)
In my case its blocking the node system call
I quit this from hidden icons in the system tray it works fine for me
when you do => npm start
- you may have seen some antivirus asks permission to add it to whitelist or add it to block list that antivirus you should stop or add whitelist to it
Solution 10:[10]
Solution 11:[11]
there is bug because your user pc name contains space , you could resolve this with this code :
> npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global
Solution 12:[12]
Run Windows PowerShell as administrator and type this:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Solution 13:[13]
npm uninstall -g create-react-app
npx create-react-app my-app
You don't need to install the create-react-app package globally. 'npx' is already installing with the latest version.
Solution 14:[14]
In your antivirus whitelist the node software
hey guys in my point of view, check your system any antivirus is running and blocking the node.exe more specifically (ByteFence Anti-malware)
In my case its blocking the node system call
I quit this from hidden icons in the system tray it works fine for me
when you do
npm start
- sometimes you may seen some antivirus asks permission to add it to whitelist or add it to block list that antivirus you should stop or add whitelist to it
Solution 15:[15]
I tried everything and nothing worked.
I then restarted my laptop, and when I tried npm init
followed with npm install create-react-app
I got an Avast potential harmful file alert, but it was ok and I confirmed it.
That create-react-app
attempt failed, but when I tried it again it worked.
It's possible that a firewall or such is blocking node from carrying out a function, hence why it's throwing a callback() never called error.
Solution 16:[16]
This worked for me: because i had network issues
npx create-react-app <app name> -timeout=60000
Solution 17:[17]
npm cache clean --force
npx create-react-app project_name --template all
cd project_name
npm start
Solution 18:[18]
try this:
npm cache clean --force
npx create-react-app myapp
It worked for me.
Solution 19:[19]
This worked for me.
npm cache clean --force
npm init -y
npx create-react-app my-app
Solution 20:[20]
please run npm cache clean --force
If you are using VS code
, please make sure you restart
the terminal.
It will be okay to start the new project.
Solution 21:[21]
First create a folder with
Mkdir (folder name)
Second Cd into the folder
Cd folder_name
Thirdly run npx create-react-app ./
This will create a new react app for you.
Solution 22:[22]
First download new version of Node Which is version 17 now in April 2022,
Secondly make directory
mkdir appName
Thirdly
cd appName
Lastly
npx create-react-app ./
This is how to get Reactjs application in React 18.
Solution 23:[23]
- sudo chown -R 1000:1000 "/home/aditya/.npm"
- npx crate-react-app
this should fix the issue.
Solution 24:[24]
If you are unable to create the app try reinstalling nodeJS in 32-bits and try it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow