title: How to enable nvm in steps in circleci 2.0?
body: <p>Here are my steps  in my </p>
  
  <pre><code>steps:
    -run:
        name: Setup nvm and npm
        command: |
          wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
          export NVM_DIR=$HOME/.nvm
          source $NVM_DIR/nvm.sh
          nvm install 8.9 &amp;&amp; nvm alias default 8.9
     -run: npm install &amp;&amp; npm run lint &amp;&amp; npm test
  </code></pre>
  
  <p>The second step always fails with this error message</p>
  
  <pre><code>/bin/bash: npm: command not found
  </code></pre>
  
  <p>I checked  <code>.bashrc</code> and I can see the following lines are added to the end of the file</p>
  
  <pre><code>export NVM_DIR="$HOME/.nvm"
  [ -s "$NVM_DIR/nvm.sh" ] &amp;&amp; \. "$NVM_DIR/nvm.sh"  # This loads nvm
  [ -s "$NVM_DIR/bash_completion" ] &amp;&amp; \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  </code></pre>
  
  <p>Circleci 2.0 invokes the step command by starting a new shell with  <code>#!/bin/bash -eo pipefail</code></p>
  
  <p>If I starts a docker (<code>docker run -i -t buildpack-deps:xenial</code>) and apply the first step, and then start a new shell via <code>#!/bin/bash -eo pipefail</code>, I can see <code>npm</code> is available on the path</p>
  
  <p>I am using docker for this project</p>
  
  <pre><code>version: 2
  jobs:
    test_main:
      docker:
        - image: buildpack-deps:xenial
  </code></pre>
  
  <p>So why does it fail in circleci 2.0 environment? How can I ensure <code>npm</code> will be available to step 2 from step 1?</p>
  
  <p>I have tried to add <code>[ -s "$HOME/.bashrc" ] &amp;&amp; \. "$HOME/.bashrc"</code> to <code>~/.bash_profile</code> (in case <code>.bashrc</code> is not executed due to the non-interactive/non-login shell)</p>
  
  <p>To reproduce the issue you can run <code>circleci build</code> with this <code>.circleci/config.yml</code> file</p>
  
  <pre><code>version: 2
  jobs:
    build:
      docker:
        - image: buildpack-deps:xenial
      steps:
        - run:
            name: Setup nvm and npm
            command: |
              wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
              # Activate nvm
              export NVM_DIR=$HOME/.nvm
              touch $HOME/.nvmrc
              source $NVM_DIR/nvm.sh
              # Use node 8.9
              nvm install 8.9 &amp;&amp; nvm alias default 8.9
              echo 8.9 &gt; $HOME/.nvmrc
              # Enable nvm in following steps
              echo '[ -s "$HOME/.bashrc" ] &amp;&amp; \. "$HOME/.bashrc"' &gt;&gt; $HOME/.bash_profile
              # To fix npm install : "node-pre-gyp: Permission denied"
              npm config set user 0
              npm config set unsafe-perm true
              npm install -g npx webpack webpack-cli jest
              node --version
              npm --version
        - run: npm install
  </code></pre>
  
  <p>You will see the following error message:</p>
  
  <pre><code>====&gt;&gt; npm install
    #!/bin/bash -eo pipefail
  npm install
  /bin/bash: npm: command not found
  Error: Exited with code 127
  Step failed
  Task failed
  </code></pre>