This script assumes nvm
is already installed on your machine, but does not assume that nvm
is set up for your current environment
It will attempt to set up nvm
for the current environment, then install the desired node version and any needed global packages that are missing
It will keep the existing version of nvm
if it finds it already set up in the environment
Invoke with
- First arg for required node version
- Following args for required npm global packages
Say you placed the script in $HOME
and need node 8
with gulp
and localtunnel
, you could run
[ -s "$HOME/nvm-start.sh" ] && . "$HOME/nvm-start.sh" 8 gulp localtunnel