0

When installing node with nvm, it works great in the terminal - you can run node applications with node path/to/app.js, as you'd expect.

However, if you create an Application Menu launcher in Kubuntu/KDE, it will not work - it can't find the node binary node unless you explicitly give it the complete path, i.e. /home/xxx/.nvm/versions/node/v12.13.1/bin app.js. When node is installed directly (via apt rather than nvm), this is not necessary.

However, even specifying the full path does not work for npm. For example, creating a menu launcher with command bash -c "cd /path/to/project ; /home/xxx/.nvm/versions/node/v12.13.1/bin/npm run script-name; read -n 1", the resulting terminal window shows /usr/bin/env: 'node': No such file or directory (the final read -n 1 is just to prevent the terminal from closing right after the error).

So the question is: why can KDE's application menu not find the node/npm binaries, and more importantly, how can one create a launcher that will work with npm?

1 Answer 1

0

Found the answer from here.

You just have to move the 3 lines that nvm adds to ~/.bashrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

into ~/.profile instead. Logout & login, and it will work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .