云功能不是下载依赖项



我正在尝试在Google Cloud函数上部署一个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依赖项块:

  "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 functions CLI尝试,我得到了以下跟踪:

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"来使它起作用。我不确定为什么会导致它破裂,但是由于它是云功能,所以我实际上不再需要任何与Express相关的东西,因此删除对我的用例来说不是问题。

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

相关内容

  • 没有找到相关文章

最新更新