我正在尝试部署一个将私有(private) npm 模块导入 Google App Engine 的 Node 应用程序。我仍然停留在 npm install
由于 Unable to authenticate, need: Basic realm="GitHub Package Registry"
而失败.
npm 身份验证的一种方法是通过 NODE_AUTH_TOKEN
环境变量。 GAE 不接受通过命令行的环境变量,只接受 app.yaml
,所以我在 Github Actions CI 过程中将我的 token 添加到 app.yaml 中。事实证明,App Engine 使用一个单独的 Cloud Build 环境来构建,它没有这个环境变量;因此,再次失败。我还尝试创建 cloudbuild.yaml
并在我的环境变量中替换,但那里没有运气。最后,我尝试通过 .npmrc
设置我的 key 。像这样:
//npm.pkg.github.com/gw-cocoon/:_authToken=$NPM_TOKEN
@gw-cocoon:registry=https://npm.pkg.github.com/gw-cocoon
并在 CI 期间插入 token 。由于同样的原因,这失败了,但我不知道为什么。此 token 在每次 CI 运行时自动生成,因此我无法使用 Google Cloud KMS。
最佳答案
我很失望地发现 using private npm modules with App Engine Standard显然根本不支持。鉴于用于构建模块化(私有(private))应用程序的 GitHub 包等越来越受欢迎,这似乎是一个非常明显的限制。
有趣的是,谷歌云函数 apparently supports私有(private) npm 模块,因此在 App Engine 中获得支持可能只是时间问题。
关于node.js - 使用 Google App Engine 对私有(private)模块进行 NPM 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59298853/