I've tried to install NodeJS
with nvm
in AWS EC2 linux as follow inside user-data:
#!/bin/bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
source ~/.bashrc
nvm install 7
After instance is successfully created and I've entered and check inside my ec2 instance, there is no nodejs
and nvm
installed when I typed like node --version
or nvm --version
.
[ec2-user@ip-0-0-0-0 ~]$ node --version
-bash: node: command not found
[ec2-user@ip-0-0-0-0 ~]$ nvm --version
-bash: nvm: command not found
and when I've checked in instance's log, found following error message.
[ 16.310115] cloud-init[3300]: => Downloading nvm as script to '/.nvm'
[ 17.053885] cloud-init[3300]: => Profile not found. Tried (as defined in $PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
[ 17.076402] cloud-init[3300]: => Create one of them and run this script again
[ 17.087459] cloud-init[3300]: => Create it (touch ) and run this script again
[ 17.092307] cloud-init[3300]: OR
[ 17.100669] cloud-init[3300]: => Append the following lines to the correct file yourself:
[ 17.117606] cloud-init[3300]: export NVM_DIR="$HOME/.nvm"
[ 17.124904] cloud-init[3300]: [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ 17.161419] cloud-init[3300]: => Close and reopen your terminal to start using nvm or run the following to use it now:
[ 17.177964] cloud-init[3300]: export NVM_DIR="$HOME/.nvm"
[ 17.185400] cloud-init[3300]: [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
user-data
box, it was not working at all. – Turkic