I've tried to install NodeJS in EC2instance - linux as follow inside user-data:
#!/bin/bash yum update -y
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR="/home/ec2-user/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
yum install git -y
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/aws-xxxx
cd aws-gat
node app.js
When instance is running and check my ec2 instance, there is no node js and nvm installed when I typed node -v
[ec2-user@ip-xxxx ~]$ nvm -v
-bash: nvm: command not found
[ec2-user@ip-xxxx ~]$ node -v
-bash: node: command not found
What I missed ? I wrote this script as I usually do in my instance and work.