【问题标题】:Node Express js in Google Cloud FunctionsGoogle Cloud Functions 中的 Node Express js
【发布时间】:2018-05-31 18:59:07
【问题描述】:

我创建了一个 expressjs 应用程序,并尝试将其部署到 Google Cloud Functions 中。
我自己开发了该应用程序,然后按照guide 将其附加到 gCloud 功能服务。 基本上,我在项目的根目录中创建了一个index.js 文件

var app = require('./app');

function App(req,res) {
    if (!req.url) {
        req.url = '/';
        req.path = '/';
    }
    return app(req,res);
}

var converter = App;

module.exports = {
    converter
};

ps。为了测试,我留下了名称转换器以符合指南,我会在它工作后立即更新它;D

我的项目现在是这样的

- myAppProject
--- index.js
--- app.js
--- package.json
--- someFolderWithCode
------ someFile.js

我压缩了代码并使用 gCloud 控制台(又名 webapp)上传 zip 并定义了函数 converter,这与我的 index.js 中导出的函数相同。
问题是我得到了这个错误

Function load error: File index.js or function.js that is expected to define function doesn't exist in the root directory.

我无法理解我错过了什么。

【问题讨论】:

    标签: node.js express google-cloud-platform google-cloud-functions


    【解决方案1】:

    我发现了这个问题。
    我压缩了myAppProject,而我应该压缩其中包含的所有文件。之后它接受了index.js 文件。

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 2020-08-06
      • 2017-09-30
      • 2019-10-23
      • 2021-07-25
      • 1970-01-01
      相关资源
      最近更新 更多