Search code examples
reactjscreate-react-app

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


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

Solution

  • 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
    ├── [email protected]
    ├── [email protected]
    └── [email protected]
    
    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!