【问题标题】:NPM authentication for private module with Google App Engine使用 Google App Engine 对私有模块进行 NPM 身份验证
【发布时间】:2020-04-05 12:09:18
【问题描述】:

我正在尝试部署一个将私有 npm 模块导入 Google App Engine 的节点应用程序。由于Unable to authenticate, need: Basic realm="GitHub Package Registry",我仍然停留在npm install 失败。

npm 身份验证的一种方法是通过NODE_AUTH_TOKEN 环境变量。 GAE 不接受通过命令行的环境变量,只接受app.yaml,所以我在我的 Github Actions CI 过程中将我的令牌添加到了 app.yaml。事实证明,App Engine 使用一个单独的 Cloud Build 环境来构建,它没有这个环境变量;因此,再次失败。我还尝试创建一个cloudbuild.yaml 并在我的环境变量中进行替换,但那里没有运气。最后,我尝试通过.npmrc 设置我的密钥,如下所示:

//npm.pkg.github.com/gw-cocoon/:_authToken=$NPM_TOKEN
@gw-cocoon:registry=https://npm.pkg.github.com/gw-cocoon

并在 CI 期间插入令牌。由于同样的原因,这失败了,但我不知道为什么。此令牌在每次 CI 运行时自动生成,因此我无法使用 Google Cloud KMS。

【问题讨论】:

标签: node.js google-app-engine npm google-cloud-platform google-cloud-build


【解决方案1】:

我很失望地发现 using private npm modules with App Engine Standard 显然根本不受支持。鉴于用于构建模块化(私有)应用程序的 GitHub 包等越来越受欢迎,这似乎是一个非常明显的限制。

有趣的是,Google Cloud Functions apparently supports 私有 npm 模块,所以在 App Engine 中获得支持可能只是时间问题。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-01-02
  • 2014-08-14
  • 1970-01-01
  • 1970-01-01
  • 2012-01-26
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多