previewjs
previewjs copied to clipboard
Add option to hide "unable to find node" message
Is your feature request related to a problem? Please describe. I'm running my projects inside WSL 2 to which I have to connect first. I have node, preview.js' dependencies and preview.js running without any issues inside WSL. When I however open a new windows of VS Code it starts by default outside of WSL and since I cannot enable preview.js to only run inside WSL it complains that node cannot be found.
I've noticed that since the alert opens the output pane it also moves the focus to it. So when I open an editor I instinctively click on the context menu to open up a project but then the preview.js extension loads and cannot find node and since it opens the output pane the context menu closes which is a bit annoying.
Here's how it looks like with preview.js:

And here it's with preview disabled:

Notice that the context menu actually closes twice - I assume the first time it's VS Code itself, but the second context menu focus loss is preview.js as it's not present in the second gif
Describe the solution you'd like It would be best if I could set preview.js to only start inside of WSL but I don't think that's possible in VS Code yet. Since if I disable it globally and then re-enable it inside WSL it just re-enables everywhere.
Alternatively it would be great if there was a setting to disable the message preview.js outputs so that the output pane is not opened if it cannot find node (and thus doesn't mess with the context menu focus).
Additional context It's not a big issue but it can sometimes be really annoying as it takes a while for preview.js to load so I'm usually already in the recent project context menu section ready to open one up when the output pane from preview.js pops up and closes the context menu altogether 😅
Hi @IgnusG, thanks for the bug report!
I'll see if that can be fixed, but better yet I'll try to make it work with WSL's version of Node automatically in the first place.
Hey @IgnusG, this should now be fixed in v1.12.0, which will automatically fall back to Node running inside WSL if it can't find it on Windows.
Would you be able to let me know if that fixes your issue?
Closing as this should be fixed, feel free to reopen if you have any issues :)
It worked very well at first. Now I got an error though (possibly unrelated cause it's the first time I see it):

And when I open that file it just says this 😅

And when I open that file it just says this 😅
Hah. These are some great logs. Thanks, I'll try to fix that so we can see what's happening under the hood...
In the meantime, would you be able to run node server.js from that directory (inside WSL) and see what happens, i.e. if the extension works again?
And if that works, would you be able to also try bash -lic "node server.js" (this is what the extension runs so it might be what's failing)?
Seems like both worked albeit a bit slow to print any text (in the end both printed Preview.js daemon server is now running on http://localhost:9315 though)
Hey @IgnusG, sorry about the delay on this one.
I've just published Preview.js v1.14 which should improve WSL support and add better logging.
Let me know how you go, I'll close this issue but don't hesitate to reopen it.