7

I am trying to create a react project i have run npx create-react-app my-app then cd my-app but when I've npm start this error has been shown:

> my-app@0.1.0 start C:\Users\USER\my-app
> react-scripts start

i 「wds」: Project is running at http://192.168.137.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\HAMOOD\my-app\public
i 「wds」: 404s will fallback to /
Starting the development server...

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn powershell ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn powershell',
  path: 'powershell',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBgACIAaAB0AHQAcAA6AC8ALwBsAG8AYwBhAGwAaABvAHMAdAA6ADMAMAAwADAAYAAiACIA'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\HAMOOD\AppData\Roaming\npm-cache\_logs\2020-08-23T13_09_04_330Z-debug.log

i have tried to to delete the node_modules then I've installed it another time but the same issue still happening

3 Answers3

12

I've found some possible solutions. Seems that you are using powershell, check firstly that you have it in your PATH as %SystemRoot%/system32/WindowsPowerShell/v1.0. After that open powershell as admin and write

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

It should help in case there is problem with powershell. OR, sometimes it could be an error while cra dev server is trying to open web browser. Someone on github said that this helped him:

This error stems from the fact that CRA tries to open your browser: In order to skip opening the browser, add BROWSER=none to your .env or .env.local file

Another way is to downgrade react scripts for project with these commands

npm install react-scripts@2.1.8
npm start
Vadim Ledyaev
  • 458
  • 1
  • 6
  • 9
  • 1
    I am trying to open the cmd as an administrator but it's not opening –  Aug 23 '20 at 13:56
  • 1
    Is it a trouble with access rights or it's just not opening? Any errors or logs? Also, what version of windows are you using? – Vadim Ledyaev Aug 23 '20 at 14:07
  • 1
    no it's just not opening no errors I am using windows 10 –  Aug 23 '20 at 14:48
  • 1
    That's strange, I definitely recommend you to check your system setup and resolve any issues with cmd or powershell, at least it will remove one source of troubles with node and cra – Vadim Ledyaev Aug 23 '20 at 15:43
  • 1
    Creating ```.env``` file where my projects ```package.json``` resides and writing there ```BROWSER=none``` helped me. I'm running Ubuntu 20.04 in WSL2 – eemilk Jul 14 '21 at 07:17
2

Goto > Control Panel\System and Security\System\Advance system setting\Enviroment variable and set system variables path C:\Windows\System32\ variable and restart your System.

2

1- First you need to edit system environment variable and locate where you have Windows Poweshell so add new in "system environment variable path"

Add Window Powershell path in system environment variable path

2- Then Open Window PoweShell as An Administraror And Write these Two Commands :

:) Upgrade Window PowerShell because your nodejs and npm is updated but powershell is not updated so its making conflict with your npm start or expo start,so you should need to upgrade windows powershell

Upgrade Window PowerShell because your nodejs and npm is updated but powershell is not updated so its making conflict with your npm start or expo start,so you should need to upgrade windows powershell.

And Then run Cmd and also run your poject npm start or expo start so quickly it will work!

enter image description here

BEST OF LUCK!

Hasnain Mehmood
  • 407
  • 5
  • 4