I would like to have automatically invoke \"nvm use\" when I run \"npm start\". So I come up with this solution:
package.json
\"scripts\": {
\"presta
Generally on a Mac, the nvm.sh file is located in your home path. Use the $HOME variable if you have multiple Mac users working on the code.
"scripts": {
"prestart": "source $HOME/.nvm/nvm.sh; nvm use"
}
I would've added this as a comment to the above response, but I'm not allowed :(
Your package.json could look like
"scripts": {
"start": "source /whereever/located/nvm.sh; nvm use; nodemon index.js"
}
To explain. The "start" line is a single shell instance. So you have to have nvm initialize the PATH in that shell instance. Also, nvm
is a shell function not an executable shell script. The nvm function lives in the shell instance, and is created by sourcing the nvm.sh file.
Sorry for the edits cuz I didn't test my first two.