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
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.
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
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.