Docs says I need to have direct path to node.js executable in shebang but for node.js installed with nvm the path is similar to /Users/[username]/.nvm/versions/node/v11.15.0/bin/node which is unique for every user. I tried to create bash script
#!/usr/bin/env bash
n=$(which node)
"$n" runner.js
But which does not return the result. Any idea how to run node.js scripts in that case? Is it possible to somehow run scripts with user environment?
which doesn't return anything probably because it's not in your PATH variable (on Unix environments, not sure what you're using).
Anyway, I think this question is better asked on a node.js forum. The maintainers are pretty overloaded right now (130+ issues, as you can see) so I'm going to go ahead and close this out.
If you find the answer to your question and think it would be useful to add to the readme, feel free to raise a PR and one of us will merge it 馃憤
@m-cat
No. When I type which in iTerm or Terminal.app it returns path to node.js as usual -> Users/[username]/.nvm/versions/node/v11.15.0/bin/node.
You closed the issue and now no one won't see the issue 馃憥. Even if it's not going to be solved someone could have some idea for a workaround. It's not question for node.js forum as it's not related to node.js itself but bitbar's execution environment.
I see, that's my bad. My apologies!
My temporary workaround is to create bash script on-the-fly with the correct path to node file. It's dirty bc you need to run it from your node.js file directory, it has hardcoded paths and does not respond to changes made in js file repository.
echo -e '#!/bin/bash' "\n$(which node) $(pwd)/[your-main-js-file]" > [path-to-bitbar-plugins]/[your-plugin-name].1m.sh
chmod +x [path-to-bitbar-plugins]/[your-plugin-name].1m.sh
I'm not bash expert but that's the easiest thing that I could figure out for now. Hope it helps someone.
As a tip for maintainers, I'd suggest to execute .bash_profile before starting the session so if user has some scripts to update PATH it will be updated.
Most helpful comment
My temporary workaround is to create bash script on-the-fly with the correct path to node file. It's dirty bc you need to run it from your node.js file directory, it has hardcoded paths and does not respond to changes made in js file repository.
I'm not bash expert but that's the easiest thing that I could figure out for now. Hope it helps someone.
As a tip for maintainers, I'd suggest to execute
.bash_profilebefore starting the session so if user has some scripts to update PATH it will be updated.