antfu / vitesse

🏕 Opinionated Vite + Vue Starter Template

Home Page:https://vitesse.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yarn run fails in WSL2 with "Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT"

mklueh opened this issue · comments

Does anyone know why and what package tries to point to powershell.exe? I'm not able to get it running in WSL 2

/usr/bin/node /usr/lib/node_modules/yarn/bin/yarn.js run dev
yarn run v1.22.17
$ vite --port 3333 --open

  vite v2.9.5 dev server running at:

  > Local: http://localhost:3333/
  > Network: use `--host` to expose

  ready in 847ms.

  > Inspect: http://localhost:3333/__inspect/

node:events:504
      throw er; // Unhandled 'error' event
      ^

Error: spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
  path: '/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBoAHQAdABwADoALwAvAGwAbwBjAGEAbABoAG8AcwB0ADoAMwAzADMAMwAvACIA'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Process finished with exit code 1

Found out it has to do something with IntelliJ.

Running npm run dev or yarn run dev from the terminal works

@mklueh It's because you have to tell (in settings) that IntelliJ to use Node & yarn from WSL. Otherwise, It may use the windows one.

You can configure it by searching Node in Settings, it will autodetect node if it's installed on WSL, you just have to pick it.

@mklueh It's because you have to tell (in settings) that IntelliJ to use Node & yarn from WSL. Otherwise, It may use the windows one.

You can configure it by searching Node in Settings, it will autodetect node if it's installed on WSL, you just have to pick it.

No, this is a node error, which means it is already the right path and the application is starting. Not related to the IDE. The problem is probably with the --open flag that tries to open a Browser, and assumes it's running on Windows instead of detecting WSL correctly. I had this issue now numerous times with different CLI tools such as Netlify as well.