I have these four lines at the start of my ec2 user data script to install nvm and Node.js. This never seems to succeed.
touch ~/.bashrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 16
The nvm installer cannot find the .bashrc and conks out:
Cloud-init v. 22.2.2 running 'modules:final' at 2025年1月24日 07:28:19 +0000. Up 14.32 seconds.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16555 100 16555 0 0 54955 0 --:--:-- --:--:-- --:--:-- 55000
=> Downloading nvm as script to '/.nvm'
=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
OR
=> Append the following lines to the correct file yourself:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
/var/lib/cloud/instance/scripts/part-001: line 6: nvm: command not found
Not sure what I'm doing wrong. Any ideas?
Mureinik
316k54 gold badges404 silver badges406 bronze badges
1 Answer 1
This seems like a bug in nvm. I was able to reproduce the error on a local Ubuntu container, and then I spun up a new container, replaced nvm 0.39.7 with the latest 0.40.1, and it worked just fine:
touch ~/.bashrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install 16
answered Jan 24, 2025 at 11:02
Mureinik
316k54 gold badges404 silver badges406 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
default
echo $SHELL.