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.
Solution
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.
Explanation
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.
Bonus PHP
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 "$@"