【问题标题】:Heroku and Node 0.10.29: Failed to replace env in configHeroku 和 Node 0.10.29:无法在配置中替换 env
【发布时间】:2014-08-02 20:30:37
【问题描述】:

为了在我的 Heroku 部署的节点应用程序中使用私有包注册表,我一直在我的项目中包含以下 .npmrc 文件:

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

NPM_AUTH 是 npm 期望形式的名称/密码哈希。

这允许我将凭据排除在版本控制之外。在节点 0.10.29 之前一切正常,当我推送到 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 git@heroku.com:myproject.git
 ! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:myproject.git'

环境变量已设置,我可以通过在 package.json 的 engines 字段中指定版本 0.10.28 再次推送它。

我希望了解以下内容:

  1. 哪些部分发生了变化:node、npm、npmconf 还是 Heroku? (相关提交和问题的链接会很棒。)
  2. 更改是故意的还是我应该提交错误报告?

【问题讨论】:

    标签: node.js heroku npm


    【解决方案1】:

    似乎在节点0.10.29 中发生了一些变化,导致它比以前在构建过程中更早地加载.npmrc 配置。我已对 Heroku Node.js buildpack 进行了更改以解决此问题。这是拉取请求:https://github.com/heroku/heroku-buildpack-nodejs/pull/114

    【讨论】:

      猜你喜欢
      • 2019-01-31
      • 1970-01-01
      • 2022-11-03
      • 2014-03-23
      • 2019-05-18
      • 2020-05-02
      • 2021-05-12
      • 2021-11-01
      • 2021-03-21
      相关资源
      最近更新 更多