matthewwithanm
matthewwithanm

Reputation: 4152

Heroku and Node 0.10.29: Failed to replace env in config

In order to use a private package registry with my Heroku-deployed node apps, I've been including the following .npmrc file in my projects:

_auth = ${NPM_AUTH}
always-auth = true
registry = https://myprivateregistry.com/

NPM_AUTH is the name/password hash in the form npm expects.

This allows me to keep the credentials out of version control. Everything was working fine until node 0.10.29 when I started getting the following error when pushing to Heroku:

♥ → git push heroku HEAD:master
Fetching repository, done.
Counting objects: 11, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 915 bytes | 0 bytes/s, done.
Total 11 (delta 8), reused 4 (delta 1)

-----> Node.js app detected
-----> Requested node range:  ~0.10.15
-----> Resolved node version: 0.10.29
-----> Downloading and installing node
-----> Restoring node_modules directory from cache
-----> Pruning cached dependencies not specified in package.json
       Error: Failed to replace env in config: ${NPM_AUTH}
           at /tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:371:13
           at String.replace (native)
           at envReplace (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:366:12)
           at parseField (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:345:7)
           at /tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:290:15
           at Array.forEach (native)
           at Conf.add (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:289:21)
           at ConfigChain.addString (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/node_modules/config-chain/index.js:244:8)
           at Conf.<anonymous> (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/node_modules/npmconf/npmconf.js:278:10)
           at fs.js:271:14


       /tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/lib/npm.js:33
           throw new Error('npm.load() required')
                 ^
       Error: npm.load() required
           at Object.npm.config.get (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/lib/npm.js:33:11)
           at exit (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/lib/utils/error-handler.js:49:27)
           at process.errorHandler (/tmp/build_fb6a1362-16ae-4753-b169-3a1bed157306/vendor/node/lib/node_modules/npm/lib/utils/error-handler.js:316:3)
           at process.emit (events.js:95:17)
           at process._fatalException (node.js:272:26)

 !     Push rejected, failed to compile Node.js app

To [email protected]:myproject.git
 ! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:myproject.git'

The environment variable is set and I'm able to push it again by specifying version 0.10.28 in my package.json's engines field.

I'm hoping to find out the following:

  1. Which of the pieces changed: node, npm, npmconf or Heroku? (A link to relevant commits and issues would be great.)
  2. Was the change was intentional or should I file a bug report?

Upvotes: 3

Views: 1191

Answers (1)

Zeke
Zeke

Reputation: 1448

It appears that something changed in node 0.10.29 that causes it to load the .npmrc configuration earlier than it used to during the build process. I have made a change to the Heroku Node.js buildpack to account for this. Here's the pull request: https://github.com/heroku/heroku-buildpack-nodejs/pull/114

Upvotes: 2

Related Questions