expo: expo in wsl cannot open JS debugger. ( because spawn powershell returns ENOENT )
Summary
I have Chrome and Edge installed on my windows
↓ my powershell result
But if i run expo start and click › Press j │ open debugger, I get this error
Error: [LaunchBrowser] Unable to find a browser on the host to open the inspector. Supported browsers: Google Chrome, Microsoft Edge
I wrote console.log on few places and found out that this line is returning ENOENT error
https://github.com/expo/expo/blob/main/packages/%40expo/dev-server/build/LaunchBrowserImplWindows.js#L123
My child_process.spawn and powershell.exe seems to be working. because this line got the result before reaching line 123
https://github.com/expo/expo/blob/main/packages/%40expo/dev-server/build/LaunchBrowserImplWindows.js#L142
I have no idea howpowershell works, My guess is that env we are passing is wrong.
What platform(s) does this occur on?
Android, iOS
SDK Version
49
Environment
expo-env-info 1.0.5 environment info:
System:
OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 18.16.1 - ~/.nvm/versions/node/v18.16.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.1/bin/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.1/bin/npm
npmGlobalPackages:
eas-cli: 3.15.0
Expo Workflow: managed
Minimal reproducible example
npx create-turbo@latest -e https://github.com/t3-oss/create-t3-turbo
cd <foldername>/app/expo
pnpm expo start
# press J
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 2
- Comments: 19
I found a workaround for anyone experiencing this issue.
Instead of trying to launch a Windows browser from WSL, you can launch a browser directly within WSL.
First, install Google Chrome in your WSL distro. You should be able to enter google-chrome and get a Chrome browser running directly from WSL.
Next go to node_modules/@expo/dev-server/build/LaunchBrowser.js
On line 72, remove IS_WSL from the if statement.
This causes the proceeding if statement to run, which checks for Linux OS, thus opening the browser in Linux.
@matart15 to me, there are only 2 things that are “painful” running Expo (Metro) under WSL
@Valetek I looks like this post did start with version 49 as you had assumed. I had been responding to a comment about the file being moved in subsequent versions. Hopefully the grep command will be helpful to others as
expocontinues to evolve.Good luck!
@Valetek I haven’t looked for it there but you should be able to use your code editor to globally search or IS_WSL.
Or on the command prompt
grep -nr IS_WSL node_modules/. (adding this to my previous post too)@Valetek On version 50.0.6 and 50.0.7 the file is at that location. I added version number and a github link to my previous post.