title: NodeJS not installed successfully in AWS EC2 inside User-data
body: <p>I've tried to install <code>NodeJS</code> with <code>nvm</code> in AWS EC2 linux as follow inside user-data:</p>
  
  <pre><code>#!/bin/bash
  
  curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
  source ~/.bashrc
  nvm install 7
  </code></pre>
  
  <p>After instance is successfully created and I've entered and check inside my ec2 instance, there is no <code>nodejs</code> and <code>nvm</code> installed when I typed like <code>node --version</code> or <code>nvm --version</code>.</p>
  
  <pre><code>[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
  </code></pre>
  
  <p>and when I've checked in instance's log, found following error message.</p>
  
  <pre><code>[   16.310115] cloud-init[3300]: =&gt; Downloading nvm as script to '/.nvm'
  [   17.053885] cloud-init[3300]: =&gt; Profile not found. Tried  (as defined in $PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
  [   17.076402] cloud-init[3300]: =&gt; Create one of them and run this script again
  [   17.087459] cloud-init[3300]: =&gt; Create it (touch ) and run this script again
  [   17.092307] cloud-init[3300]: OR
  [   17.100669] cloud-init[3300]: =&gt; 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" ] &amp;&amp; \. "$NVM_DIR/nvm.sh"  # This loads nvm
  [   17.161419] cloud-init[3300]: =&gt; 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" ] &amp;&amp; \. "$NVM_DIR/nvm.sh"  # This loads nvm
  </code></pre>