open: Open Unable to Connect to localhost on Windows WSL (v. 7.0.0)
For some reason I cannot open to my localhost port with the current version of the package (7.0.0). Attempting to do so yields the following error:
Windows cannot find '\http://localhost:3000\'. Make sure you typed the name correctly, and then try again.
Here is my JavaScript code:
import express from 'express';
import path from 'path';
import open from 'open';
const app = express();
const port = process.env.PORT || 3000;
app.get(['/'], function(req, res) {
res.sendFile(path.join(__dirname, '../public/index.html'));
});
app.listen(port, function(err) {
if (err) {
console.error(err);
} else {
console.info(`App listening on port ${port}`);
open('http://localhost:' + port);
}
});
Note that everything works correctly on version 6.4.0, and I can open to my localhost just fine with that. It’s only on 7.0.0 that I’m seeing this issue.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 19 (6 by maintainers)
Commits related to this issue
- Downgrade to open v6 because of Windows WSL issue Ref: https://github.com/sindresorhus/open/issues/154 Ref: https://github.com/facebook/create-react-app/pull/8364 — committed to karlhorky/heml by karlhorky 4 years ago
- downgrade to open v6 due to https://github.com/sindresorhus/open/issues/154 — committed to green3g/vscode-arcgis-assistant by green3g 4 years ago
- Upgrade to `open@7.0.2` Ref: https://github.com/sindresorhus/open/issues/154#issuecomment-583789695 — committed to karlhorky/heml by karlhorky 4 years ago
If I have to make a guess I will think it is because node thinks it is in Unix, therefore ignore the
windowsVerbatimArgumentsoption.@herberttn i created very simple repro case. Just clone and run
If you install open@6 it will starts workimg
node index.js. I used WSL1 and node 10.Just a heads up: this should be fixed now via #166 and #168.
Yeah, I’ve arrived at the same conclusion. The sad part is I’ve not been able to find any documentation that even begins to explain why. I guess we could just check if we’re in WSL (as some other caveats already do).
@sindresorhus would you be comfortable with it?
@FKobus The final PR (#168) landed in release v7.0.2. (#166 itself landed in v7.0.1)
@herberttn my bad. I tried to reproduce it again, couldn’t reproduce it on Windows. Only on WSL for me