Reputation: 2027
I'm running Manjaro, I have node in PATH, it's located at /usr/bin/node
and I can invoke it from the terminal using node
, as expected. But when I try to add the interpreter to WebStorm, when I open the dialog for adding Node & npm executables and navigate to /usr/bin
, it simply doesn't show up there. I've installed WebStorm through flatpak. Any ideas?
Upvotes: 2
Views: 3918
Reputation: 43
For anyone stumbling onto this in the future, and your flatpak installation detects a node interpreter (using Shift+F10
works), but using node
or npm
via WebStorm's terminal doesn't work, you may be able to fix that by switching the default terminal in WebStorm from sh
to bash
:
File
> Settings
> Tools
> Terminal
; then set Shell Path
to /bin/bash
If this doesn't work for you (and nor does Sarke's answer), skip to the second part of my answer.
This worked for me, having installed WebStorm via the Pop Shop. Honestly, I'm not sure why that fixes it, nor why WebStorm doesn't automatically use the default shell.
If you've followed Sarke's answer (there was no default node interpreter, or you've skipped here from part 1 of my answer) and you're still having trouble, you can follow roughly the same instructions to allow WebStorm to access your entire host terminal:
printf '#!/usr/bin/env sh\nflatpak-spawn --host bash "$@"\n' > ~/flatpak-bash
chmod a+x ~/flatpak-bash
Then set that as your default terminal (using the same instructions from part 1, but with flatpak-bash
), which will allow you to run your entire terminal outside of flatpak's sandbox.
However, by doing so, you'll run into this error, which means you'll lose the ability to terminate programs (i.e. use Ctrl+C
and Ctrl+V
) within WebStorm. In theory, part 3 should solve that problem, though I was unable to get it working myself due to incomplete documentation.
To avoid this error (i.e. the ability to terminate programs, etc.), you should (in theory) be able to use 1player's host-spawn, which reimpliments flatpak-spawn
and should support termination of programs in WebStorm. To do so, you'll need to "install" host-spawn
(i.e. download a binary, give it execution permissions chmod a+x ~/host-spawn
, move it to ~/bin
), then create a symlink for your chosen shell. Hopefully there is better documentation on its homepage by the time someone finds this, as I was not able to actually get this working myself.
Upvotes: 1
Reputation: 3235
Flatpak is sandboxed, so it cannot directly run anything that is on the host, outside of the user's home directory.
However, there is a way to get around this, by having flatpak run the host binary using the flatpak-spawn
.
1. Run these two commands in shell:
printf '#!/usr/bin/env sh\nflatpak-spawn --host node "$@"\n' > ~/flatpak-node
chmod a+x ~/flatpak-node
2. In WebStorm, go to
File
> Settings
> Languages & Frameworks
> Node.js and NPM
(or TypeScript
)
and set the Node Interpreter
to ~/flatpak-node
.
This will create an executable file called flatpak-node
in your home directory, with this content:
#!/usr/bin/env sh
flatpak-spawn --host node "$@"
This will tell Flatpak to run the node
binary on the host and pass along any parameters. It works because the executable we created is in the home directory, and flatpak-spawn
can run the command as if it was on the host (outside of the sandbox).
Personally, I make the file ~/bin/flatpak-node
, but you can put it anywhere in the home directory.
Of note is this same solution works for PhpStorm and the php
interpreter. Simply replace node
with php
in the content and filename:
#!/usr/bin/env sh
flatpak-spawn --host php "$@"
Upvotes: 3
Reputation: 2027
Managed to fix this by uninstalling the flatpak
WebStorm instance that I had installed and installed WebStorm through Snap store. It simply worked afterwards, but I'll keep the question open in case anyone has a better solution.
Upvotes: 4