title: Failed to replace env in config using Bash & NPM
body: <p>I'm trying to use a private NPM module in my application, and need to set appropriate NPM access tokens so that third-party tools (Heroku and CI) can access, and install the module.</p>
  
  <p>I have the following line set in my <code>~/.bash_profile</code>:</p>
  
  <pre><code>export NPM_TOKEN="XXXXX-XXXXX-XXXXX-XXXXX"
  </code></pre>
  
  <p>and then in the <code>/path/to/app/.npmrc</code> I have</p>
  
  <pre><code>//registry.npmjs.org/:_authToken=${NPM_TOKEN}
  </code></pre>
  
  <p>However, whenever I open my terminal, I get the following error on startup:</p>
  
  <pre><code>Error: Failed to replace env in config: ${NPM_TOKEN}
      at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:429:13
      at String.replace (native)
      at envReplace (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:424:12)
      at parseField (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:400:7)
      at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:338:17
      at Array.forEach (native)
      at Conf.add (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:337:23)
      at ConfigChain.addString (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
      at Conf.&lt;anonymous&gt; (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/config/core.js:325:10)
      at /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16
  /Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/npm.js:29
  throw new Error('npm.load() required')
  ^
  
  Error: npm.load() required
  at Object.npm.config.get (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/npm.js:29:11)
  at exit (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/utils/error-handler.js:58:40)
  at process.errorHandler (/Users/marcthomas/.nvm/versions/node/v4.2.1/lib/node_modules/npm/lib/utils/error-handler.js:385:3)
  at emitOne (events.js:77:13)
  at process.emit (events.js:169:7)
  at process._fatalException (node.js:221:26)
  nvm is not compatible with the npm config "prefix" option: currently set to ""
  Run `nvm use --delete-prefix v4.2.1 --silent` to unset it.
  </code></pre>
  
  <p>However, running <code>echo $NPM_TOKEN</code> returns the correct token, so the variable definitely exists.</p>
  
  <p>If I run <code>source ~/.bash_profile</code> the error disappears, and I can install as normal.</p>
  
  <p>Any help appreciated as I'm bashing my head against a wall at this problem!</p>