9

When ever I try to execute npm start, this is what happens. I think there is some issue with powershell and not with npm because npm starts the development server. BTW I created basic react app using npx create-react-app. I checked, powershell file is there in the specified location and it is working as well. Guild me what should I do in order to resolve the error.

events.js:353
  throw er; // Unhandled 'error' event
  ^
Error: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell',
  path: 'C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA=='
  ]
}

Error Image

3
  • Try running the app from a terminal (cmd.exe) Commented Jul 7, 2021 at 9:47
  • I am running it in cmd.exe only Commented Jul 7, 2021 at 12:08
  • Please paste the relevant messages as text as well so they can be searched for. Commented Jul 7, 2021 at 18:06

6 Answers 6

6

I faced with a same problem on Windows 10. And solution was a pretty simple - just run your commands in git bush console.

Sign up to request clarification or add additional context in comments.

3 Comments

After a few hours of searching the internet, this solution actually worked, thank you!
I just spent hours installing different node versions and reinstalling until I tried this. And it WORKED!?!? Thank you!
the solution still works
4

Try export BROWSER=none

Reference: https://github.com/facebook/create-react-app/issues/7251#issuecomment-827602712

I got this problem when using podman and wsl

Comments

1

So after trying everything and looking for the error on every possible website. I still wasn't able to resolve the error. Then I personally talked to someone regarding the error and he suggested me to run it in Windows Sub-system for Linux (WSL). I exactly did that and installed WSL with Linux 20.04 LTS. Now I am using Unix terminal to create the react app. It isn't the best solution for the problem, but yeah it does work and saves a lot of time!

Comments

1

Step 1:(reason of the error)

go to C:\Windows\System32\WindowsPowerShell\v1.0 and then you will not be found powershell.exe file that folder.

Step 2: (solution of the error)

download powershell.exe file online or just copy and paste this file in C:\Windows\System32\WindowsPowerShell\v1.0

https://www.exefiles.com/en/exe/powershell-exe/ - To download powershell.exe file online

Comments

1

I don't know why this error occurs , I sated paths and all but nothing it worked. But I have one solution

simply write your code in git bash . you can also change your vs code terminal to git bash. Link to change = " https://blog.danielpadua.dev/posts/git-bash-with-vscode/ ".

Comments

0

I had the same issue on WSL and resolved by modifying my /etc/wsl.conf

wsl.conf that caused the error (apparently by modifying the path to powershell.exe into something wrong):

[network] 
generateResolvConf = false 
mount -t drvfs C: /mnt/c 
root = / 
options = metadata

wsl.conf that works:

[network] 
generateResolvConf = false 

Some background for this error causing wsl.conf:

I had issues accessing /mnt/c from my WSL and had changed the wsl.conf originally into the error causing one. As instructed here: https://github.com/microsoft/WSL/issues/1864#issuecomment-506005637

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.