Я попытался установить NodeJS
с nvm
в AWS EC2 linux, как показано ниже внутри пользовательских данных:
#!/bin/bash
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
source ~/.bashrc
nvm install 7
После того, как экземпляр успешно создан, и я вошел и проверил свой экземпляр ec2, nodejs
и nvm
не установлены, когда я набрал node --version
или 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
и когда я проверил журнал экземпляра, нашел следующее сообщение об ошибке.
[ 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