How to fix “Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT”

Background

I’m running a Kubernetes cluster in Docker using kind. One of the pods in the cluster is running a React app using react-scripts start. After the console shows ‘Starting the development server’, it throws an error that powershell cannot be found and exits. Below is the stack trace:

 

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> 30 node:events:491
31 throw er; // Unhandled 'error' event
32 ^
33
34 Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT
35 at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
36 at onErrorNT (node:internal/child_process:485:16)
37 at processTicksAndRejections (node:internal/process/task_queues:83:21)
38 Emitted 'error' event on ChildProcess instance at:
39 at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
40 at onErrorNT (node:internal/child_process:485:16)
41 at processTicksAndRejections (node:internal/process/task_queues:83:21) {
42 errno: -2,
43 code: 'ENOENT',
44 syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
45 path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
46 spawnargs: [
47 '-NoProfile',
48 '-NonInteractive',
49 '–ExecutionPolicy',
50 'Bypass',
51 '-EncodedCommand',
52 'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA=='
53 ]
54 }
55 error Command failed with exit code 1.
</code>
<code> 30 node:events:491 31 throw er; // Unhandled 'error' event 32 ^ 33 34 Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT 35 at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19) 36 at onErrorNT (node:internal/child_process:485:16) 37 at processTicksAndRejections (node:internal/process/task_queues:83:21) 38 Emitted 'error' event on ChildProcess instance at: 39 at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) 40 at onErrorNT (node:internal/child_process:485:16) 41 at processTicksAndRejections (node:internal/process/task_queues:83:21) { 42 errno: -2, 43 code: 'ENOENT', 44 syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', 45 path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe', 46 spawnargs: [ 47 '-NoProfile', 48 '-NonInteractive', 49 '–ExecutionPolicy', 50 'Bypass', 51 '-EncodedCommand', 52 'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA==' 53 ] 54 } 55 error Command failed with exit code 1. </code>
 30 node:events:491
 31       throw er; // Unhandled 'error' event
 32       ^
 33                                                                                                                          
 34 Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT                                        
 35     at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
 36     at onErrorNT (node:internal/child_process:485:16)
 37     at processTicksAndRejections (node:internal/process/task_queues:83:21)
 38 Emitted 'error' event on ChildProcess instance at:
 39     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
 40     at onErrorNT (node:internal/child_process:485:16)
 41     at processTicksAndRejections (node:internal/process/task_queues:83:21) {                                             
 42   errno: -2,
 43   code: 'ENOENT',
 44   syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
 45   path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
 46   spawnargs: [
 47     '-NoProfile',
 48     '-NonInteractive',
 49     '–ExecutionPolicy',
 50     'Bypass',
 51     '-EncodedCommand',
 52     'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAwADAAMAAiAA=='
 53   ]
 54 }
 55 error Command failed with exit code 1.

Other Information

I’m using WSL2 with Docker and Ubuntu. Running wsl -l -v gives this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> NAME STATE VERSION
* Ubuntu-22.04 Running 2
docker-desktop-data Running 2
docker-desktop Running 2
</code>
<code> NAME STATE VERSION * Ubuntu-22.04 Running 2 docker-desktop-data Running 2 docker-desktop Running 2 </code>
  NAME                   STATE           VERSION
* Ubuntu-22.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2

docker context ls returns:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>NAME TYPE DESCRIPTION DOCKER ENDPOINT
KUBERNETES ENDPOINT ORCHESTRATOR
default moby Current DOCKER_HOST based configuration npipe:////./pipe/docker_engine
desktop-linux * moby Docker Desktop npipe:////./pipe/dockerDesktopLinuxEngine
desktop-windows moby Docker Desktop npipe:////./pipe/dockerDesktopWindowsEngine
</code>
<code>NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default moby Current DOCKER_HOST based configuration npipe:////./pipe/docker_engine desktop-linux * moby Docker Desktop npipe:////./pipe/dockerDesktopLinuxEngine desktop-windows moby Docker Desktop npipe:////./pipe/dockerDesktopWindowsEngine </code>
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT
    KUBERNETES ENDPOINT   ORCHESTRATOR
default             moby                Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine

desktop-linux *     moby                Docker Desktop                            npipe:////./pipe/dockerDesktopLinuxEngine

desktop-windows     moby                Docker Desktop                            npipe:////./pipe/dockerDesktopWindowsEngine

I manually checked the filesystem for WSL and confirmed that the powershell executable is there. After opening a new terminal and running wsl, cd /mnt/c/Windows/System32/WindowsPowerShell/v1.0 and doing ls:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Certificate.format.ps1xml Help.format.ps1xml Registry.format.ps1xml getevent.types.ps1xml pspluginwkr.dll
Diagnostics.Format.ps1xml HelpV3.format.ps1xml Schemas ko-KR pwrshmsg.dll
DotNetTypes.format.ps1xml Modules SessionConfig **powershell.exe** types.ps1xml
Event.Format.ps1xml PSEvents.dll WSMan.Format.ps1xml powershell.exe.config typesv3.ps1xml
Examples PowerShellCore.format.ps1xml en powershell_ise.exe zh-CN
FileSystem.format.ps1xml PowerShellTrace.format.ps1xml en-US powershell_ise.exe.config zh-TW
</code>
<code>Certificate.format.ps1xml Help.format.ps1xml Registry.format.ps1xml getevent.types.ps1xml pspluginwkr.dll Diagnostics.Format.ps1xml HelpV3.format.ps1xml Schemas ko-KR pwrshmsg.dll DotNetTypes.format.ps1xml Modules SessionConfig **powershell.exe** types.ps1xml Event.Format.ps1xml PSEvents.dll WSMan.Format.ps1xml powershell.exe.config typesv3.ps1xml Examples PowerShellCore.format.ps1xml en powershell_ise.exe zh-CN FileSystem.format.ps1xml PowerShellTrace.format.ps1xml en-US powershell_ise.exe.config zh-TW </code>
Certificate.format.ps1xml  Help.format.ps1xml             Registry.format.ps1xml  getevent.types.ps1xml      pspluginwkr.dll
Diagnostics.Format.ps1xml  HelpV3.format.ps1xml           Schemas                 ko-KR                      pwrshmsg.dll
DotNetTypes.format.ps1xml  Modules                        SessionConfig           **powershell.exe**             types.ps1xml
Event.Format.ps1xml        PSEvents.dll                   WSMan.Format.ps1xml     powershell.exe.config      typesv3.ps1xml
Examples                   PowerShellCore.format.ps1xml   en                      powershell_ise.exe         zh-CN
FileSystem.format.ps1xml   PowerShellTrace.format.ps1xml  en-US                   powershell_ise.exe.config  zh-TW

Kindly advise how I can go about troubleshooting this. It’s a real headache, any help would be greatly appreciated

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật