Leo*_*Leo 8 npm google-cloud-platform google-cloud-functions
我目前正在尝试使用来自 GitHub 包注册表 (npm.pkg.github.com) 的(私有)包部署 node.js 云函数。
根据此处的官方文档,通过添加带有访问令牌的 .npmrc 文件来支持使用私有模块,但是没有提及使用自定义注册表。
我与 package.json 和其余代码一起上传到 Cloud Functions 的 .npmrc 如下所示:
registry=https://npm.pkg.github.com/<myorg>
//npm.pkg.github.com/:_authToken=<mytoken>
Run Code Online (Sandbox Code Playgroud)
但是,由于以下原因部署失败:
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/<mypackage> - Not found
npm ERR! 404
npm ERR! 404 '<mypackage>' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
Run Code Online (Sandbox Code Playgroud)
如您所见,.npmrc 中的注册表定义似乎被忽略了,因为它试图从 npmjs.org 中提取包,而实际上它并不存在。
Google Cloud Functions 不支持自定义注册表吗?
编辑:添加详细日志输出
Deploying function (may take a while - up to 2 minutes)...failed.
DEBUG: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/<redacted> - Not found\nnpm ERR! 404 \nnpm ERR! 404 '<redacted>' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 It was specified as a dependency of 'functions'\nnpm ERR! 404 \nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git url.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2020-02-12T14_14_22_565Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @ preinstall: `./install-function-dependencies`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @ preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2020-02-12T14_14_22_586Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "BDE5340F"}}
Traceback (most recent call last):
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 981, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 807, in Run
resources = command_instance.Run(args)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/functions/deploy.py", line 307, in Run
return _Run(args, track=self.ReleaseTrack())
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/surface/functions/deploy.py", line 263, in _Run
op, do_every_poll=TryToSetInvokerPermission)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 306, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 353, in WaitForFunctionUpdateOperation
do_every_poll=do_every_poll)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 137, in Wait
_WaitForOperation(client, request, notice, do_every_poll)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 111, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
result = func(*args, **kwargs)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 70, in _GetOperationStatus
raise exceptions.FunctionsError(OperationErrorToString(op.error))
FunctionsError: OperationError: code=3, message=Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`npm_install` had stderr output:\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/<redacted> - Not found\nnpm ERR! 404 \nnpm ERR! 404 '<redacted>' is not in the npm registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 It was specified as a dependency of 'functions'\nnpm ERR! 404 \nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git url.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2020-02-12T14_14_22_565Z-debug.log\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! @ preinstall: `./install-function-dependencies`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the @ preinstall script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /builder/home/.npm/_logs/2020-02-12T14_14_22_586Z-debug.log\n\nerror: `npm_install` returned code: 1", "errorType": "InternalError", "errorId": "BDE5340F"}}
Run Code Online (Sandbox Code Playgroud)
Google Cloud Functions 不支持自定义注册表吗?
Google Cloud Functions 应支持自定义注册表。您使用的是哪个版本的 Nodejs?还报告了其他一些类似的问题:运行时不支持Nodejs 10 的私有 npm 包。
线程中提到:
我想通知您,Cloud Functions 工程团队已推出一项更改来解决此问题。您可以随意再次尝试从 Node.js 8 迁移到 Node.js 10。此次推出解决了尝试安装私有软件包时的 404 NOT_FOUND 问题。
另外,我建议使用环境变量测试部署云函数。
gcloud functions deploy functionName
--region europe-west1
--runtime nodejs10
--source=SOURCE
--set-env-vars= NPM_REGISTRY=<your private registry URL>, NPM_SCOPE=<@private-registry-scope>, NPM_CONFIG_EXTRA=auth_token
Run Code Online (Sandbox Code Playgroud)
Nodejs10链接的问题似乎再次出现
| 归档时间: |
|
| 查看次数: |
639 次 |
| 最近记录: |