云功能不下载依赖关系

时间:2017-09-08 15:31:54

标签: google-cloud-functions

我正在尝试在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依赖关系阻止:

  "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在本地运行functions deploy runApp --trigger-http包没有错误,并且可以通过我的本地计算机完成我想要的任何操作。只有在尝试在云端设置

时才会出现错误

我还使用this answer中提到的gcloud beta functions标记通过--verbose 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

1 个答案:

答案 0 :(得分:0)

我设法通过简单地移除"express-healthcheck": "^0.1.0"来实现它。我不确定为什么会导致它中断,但由于它是云功能,我实际上不需要任何与Express相关的内容,因此删除对我的用例来说不是问题。

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