gpt4 book ai didi

google-cloud-functions - 云功能不下载依赖项

转载 作者:行者123 更新时间:2023-12-01 15:50:42 24 4
gpt4 key购买 nike

我正在尝试在 Google Cloud Functions 上部署 Node.js 应用程序,但它似乎没有下载我的任何依赖项。每当我的代码遇到 require 行时,它就会抛出以下错误:

Deployment failure:
Function load error: Code in file app.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'googleapis'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/app.js:1:63)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

我的 package.json 依赖 block :

  "dependencies": {
"actions-on-google": "^1.0.9",
"body-parser": "^1.15.2",
"chai-as-promised": "^6.0.0",
"express": "^4.14.0",
"express-healthcheck": "^0.1.0",
"googleapis": "^19.0.0",
"https": "^1.0.0",
"istanbul": "^0.4.5",
"newrelic": "^1.40.0",
"nodemailer": "^4.0.1",
"querystring": "^0.2.0",
"request": "^2.81.0",
"string-format": "^0.5.0",
"universal-analytics": "^0.4.13",
"xml2js": "^0.4.17"
},

有没有办法强制安装,或者我这样做的方式有问题吗?我通过命令 functions deploy runApp --trigger-http 在本地运行 functions 包时没有出现任何错误,并且可以通过我的本地计算机执行我想执行的所有操作。该错误仅在尝试在云中进行设置时发生

我还尝试使用 --verbose 标志通过 gcloud beta 函数 CLI,如 this answer 中所述我得到了以下痕迹:

DEBUG: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error in the build environment
Traceback (most recent call last):
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 789, in Execute
resources = args.calliope_command.Run(cli=self, args=args)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 754, in Run
resources = command_instance.Run(args)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 482, in Run
return self._UpdateFunction(location, function)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 364, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/surface/functions/deploy.py", line 441, in _UpdateFunction
operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 108, in Wait
_WaitForOperation(client, request, notice)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 83, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 212, in RetryOnResult
result = func(*args, **kwargs)
File "/Users/<username>/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 47, in _GetOperationStatus
raise exceptions.FunctionsError(util.GetOperationError(op.error))
FunctionsError: OperationError: code=13, message=Error in the build environment

最佳答案

我设法通过简单地删除 "express-healthcheck": "^0.1.0" 让它工作。我不确定为什么会导致它崩溃,但由于它是 Cloud Functions,我实际上不再需要任何与 Express 相关的东西,所以删除对我的用例来说不是问题。

如果有人知道为什么这会导致错误,请在这里发帖,我很好奇

关于google-cloud-functions - 云功能不下载依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46119936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com