'Create React App Error when trying to run command npx create react app: spawn UNKNOWN
When I try to run a simple npx create-react-app
i received this error:
D:\>npx create-react-app abc
npx: installed 67 in 4.255s
Creating a new React app in D:\abc.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
Aborting installation.
Unexpected error. Please report it as a bug:
Error: spawn UNKNOWN
at ChildProcess.spawn (internal/child_process.js:403:11)
at Object.spawn (child_process.js:553:9)
at spawn (C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\node_modules\cross-spawn\index.js:12:24)
at C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:407:19
at new Promise (<anonymous>)
at install (C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:359:10)
at C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:485:16
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
errno: -4094,
code: 'UNKNOWN',
syscall: 'spawn'
}
Deleting generated file... package.json
Deleting abc/ from D:\
Done.
I'm using windows 10 version 20H2 and node v14.15.4.
I've also made an issue on the official create-react-app
github here
Solution 1:[1]
It seems that there is issue with write permission.
Try running npx create-react-app myapp
from cmd with elevated permissions, i.e., run cmd as Admin and then try to create / scaffold your app.
Solution 2:[2]
I guess this error occurred because of unsupported globally install create-react-app
.
There is a tiny point in this problem, and it is there is global installs of create-react-app
are no longer supported. So at the first, run this command
npm uninstall -g create-react-app
Then install create-react-app
in this way
npm install create-react-app
Then create your react app
npx create-react-app my-app
Solution 3:[3]
You can try using:
npm cache clear --force
and retry again.
As per the website https://create-react-app.dev/docs/getting-started/, it is mentioned :
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 or yarn global remove create-react-app to ensure that npx always uses the >latest version.
Solution 4:[4]
Yesterday I was having the same issue. TBH I didn't know what cause it either but after running through some websites and YouTube tutorials I finally discovered the way to solve this problem.
First of all, you need to know what best node version that work on your PC or laptop base on what system it used.
Second, you go to run administration by clicking windows WIN+r, write %tempt%
and delete all the files inside but skip those that can not be deleted, then once again write prefetch
on search bar in run administration and also delete all the files inside just like before.
After that open Node.js command prompt
(you can find it on search explore bar) but don't forget to already installed the Node.js
. Click on the arrow and choose run as administrator with that the command prompt interface would be open.
Notice that the default writing already in C:\Windows\System32>
, so you need to make the folder inside System32
section in windows. Let's say you make this examplereactjs
( Make sure using non-cap letters, because I don't know why mine won't run if I used caps letter), after that, you can make your npx
just like usual so it would be like this:
C:\Windows\system32>cd examplereactjs
Press enter, it would be like this:
C:\Windows\system32\examplereactjs>npx create-react-app examplereactjs
Press enter, and wait for couple minutes. You can start with npm start
to open the local host browser.
This method works for me and I found it by accident actually. If this doesn't work for you, I don't know what else can. I'm still a newbie in this field and I have no idea what would cause if you messing with run administration, well I'm just here to help. Anyway let me know if this method works for you as well.
Solution 5:[5]
if reinstall create-react-app is fail and also you already try to run cmd with admin privileges but still not fix it. Try to disable your antivirus and run it once again, work like a charm for me.
Solution 6:[6]
On running this command, if this error occur then try to disable antivirus or simply when pop up comes of antivirus then click on the link in the antivirus pop up then there is no error. Work for me.
Solution 7:[7]
Well, I had the same issue, try to use "npm audit fix --force".
Solution 8:[8]
Just Uninstall the antivirus from your system!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | mayank1513 |
Solution 2 | S. Hesam |
Solution 3 | Shriyacodes |
Solution 4 | Toni |
Solution 5 | Azri Perisiben |
Solution 6 | Juhi Kalawat |
Solution 7 | Krzysztof |
Solution 8 | Thiruppathy |