I've got a Debian WSL2 install that I'm using to write some cross platform C code. As part of the CMake setup, I'm calling a non-global install of npm (which I installed using nvm). This works fine when running interactively, but when run from the CLion Run configuration, it isn't aware of the NVM install - likely because it's not sourcing the bash_profile before running. How can I get a non-interactive shell to run interactively in this context?
To correctly find your NPM install through NVM, you can use a combination of sudo
and source
. The key is to always source nvm.sh
before attempting to use anything installed by npm
add_custom_command(
COMMAND sudo -u <your user> /path/to/script.sh
...
)
#!/bin/bash
# other init stuff
# before your first npm/nvm call
source "$HOME/.nvm/nvm.sh"
# now you can use anything installed by npm