I can't create app using "npx create-react-app my-app" - reactjs

I'm trying to create a react app with "npx create-react-app my-app" but I'm getting this error.
PS C:\Users\m.saral\Desktop\app> npx create-react-app my-app
Creating a new React app in C:\Users\m.saral\Desktop\app\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
Aborting installation.
Error: spawn UNKNOWN
at ChildProcess.spawn (node:internal/child_process:420:11)
at Object.spawn (node:child_process:733:9)
at spawn (C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\node_modules\cross-spawn\index.js:12:24)
at C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:383:19
at new Promise (<anonymous>)
at install (C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:334:10)
at C:\Users\m.saral\AppData\Roaming\npm\node_modules\create-react-app\createReactApp.js:461:16
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
errno: -4094,
code: 'UNKNOWN',
syscall: 'spawn'
Deleting generated file... package.json
Deleting my-app/ from C:\Users\m.saral\Desktop\app
Done.
PS C:\Users\m.saral\Desktop\app> node -v
v16.18.0
I tried running command prompt as administrator
I tried:
npm uninstall -g create-react-app
npm uninstall create-react-app
I deleted and reinstalled Nodejs
npm install npm#latest -g
Node Version: v16.18.0
Npm Version: 8.19.2

Please try with the Latest nodejs Version For Window https://nodejs.org/en/
Also check npm Version as WEll

Problem solved
I could not find why the problem was solved when trying randomly
PS C:\Users\m.saral\Desktop\app\my-app> npm -v
8.19.2
PS C:\Users\m.saral\Desktop\app\my-app> npx -v
8.19.2
PS C:\Users\m.saral\Desktop\app\my-app> node -v
v16.18.0
PS C:\Users\m.saral\Desktop\app\my-app> npm -g list
C:\Users\m.saral\AppData\Roaming\npm
├── create-react-app#5.0.1
├── npm#8.19.2
└── tar#2.0.0
PS C:\Users\m.saral\Desktop\app> npx create-react-app my-app
Creating a new React app in C:\Users\m.saral\Desktop\app\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1392 packages in 1m
212 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
added 56 packages in 6s
212 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1448 packages in 2s
212 packages are looking for funding
run `npm fund` for details
9 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created my-app at C:\Users\m.saral\Desktop\app\my-app
Inside that directory, you can run several commands:
npm start
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd my-app
npm start
Happy hacking!

Related

unable to create react app : terminal gets stuck whenever i run command

whenever i run command npm init react-app my-app my terminal gets stuck here
PS C:\Users\USER> npm install -g create-react-app
C:\Users\USER\AppData\Roaming\npm\create-react-app ->
C:\Users\USER\AppData\Roaming\npm\node_modules\create-react-app\index.js
create-react-app#3.4.1 added 98 packages from 46 contributors in 136.484s PS C:\Users\USER> npm init react-app my-app
Creating a new React app in C:\Users\USER\my-app.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
and nothing happens after this..
when i ran command npm init react-app my-app --verbose the terminal got stuck here:
PS C:\Users\USER> cd desktop PS C:\Users\USER\desktop> npm init
react-app my-app --verbose npm info it worked if it ends with ok npm
verb cli [ npm verb cli 'C:\Program Files\nodejs\node.exe', npm
verb cli
'C:\Users\USER\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
npm verb cli 'init', npm verb cli 'react-app', npm verb cli
'my-app', npm verb cli '--verbose' npm verb cli ] npm info using
npm#6.14.8 npm info using node#v12.18.3 [..................] - :
info using node#v12.18.3 Creating a new React app in
C:\Users\USER\desktop\my-app.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
[..................] - : info using node#v12.18.3
nothing happened after this, waited for more 2 hours..
i have tried literally everything like: using npx creat-react-app my-app command after uninstalling create-react-app global package, updated node and npm to the latest versions, reinstalled node 3 times and so on.
it's been months that i'm stuck here and not be able to create my app. PLEASE, ANYONE, HELP. PLEASE..

I have been trying to create a new react project with npx create-react-app, but I am getting an error

Creating a new React app in C:\Users\USER\Desktop\test\myapp.
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 '...+g6qNdDLTEelbre6dbfGb'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2020-04-05T03_05_27_161Z-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 myapp/ from C:\Users\USER\Desktop\test
Done.
please run the following command in Command Line:
npm cache clean --force
then run
create-react-app <project Name>
if you still getting the problem, uninstall the old and download new and remove all npm folders.
if still didn't help, you can switch from npm to yarn
npm install -g yarn
// Method 1
yarn global add create-react-app
create-react-app <projectname>
// Method 2 work on yarn 0.25+
yarn create react-app my-app

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

cannot create a new react project using create-react-app

I am trying to create a new react project with create-react-app but each time it fails because of this error.......
I am using npm version 6.3.0 and node version 10.8.0
I don't know what to do............
Creating a new React app in C:\Users\Demonblade\Desktop\test.
Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! <https://npm.community>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Demonblade\AppData\Roaming\npm-cache\_logs\2018-08-09T15_27_48_357Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting test / from C:\Users\Demonblade\Desktop
Done.
Use npx (it comes with npm 5.2+).
From the react docs:
You’ll need to have Node >= 6 and npm >= 5.2 on your machine. To
create a project, run:
npx create-react-app my-app
cd my-app
npm start

executing create-react-app gives an error

I get the following error when I run create-react-app my-new-app. My npm version is 6.1.0 and node version is 8.11.3
$ create-react-app my-new-app
Creating a new React app in C:\Users\home\Desktop\Web Development\7.
React\my-new-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 '...ectories":
{},"dist"
:{'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\home\AppData\Roaming\npm-cache\_logs\2018-06-
16T12_46_38_1
22Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-
scripts
has failed.
Deleting generated file... package.json
Deleting my-new-app / from C:\Users\home\Desktop\Web Development\7. React
Done.
Try the below command:
npm cache clean --force
Maybe you have an outdated create-react-app version.
If you have npm 6, then you also have npx. Using npx you can just do:
npx create-react-app my-new-app
And it will use the latest create-react-app, even if you don't have it installed.
Check the documentation

Resources