代码之家  ›  专栏  ›  技术社区  ›  r4id4

Google云功能中的Node Express js

  •  0
  • r4id4  · 技术社区  · 6 年前


    我自己开发了这个应用程序,然后遵循了以下步骤 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
    };
    

    注意:为了测试,我让名称转换器与指南保持一致,一旦它起作用,我就会更新它;D

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

    我压缩了代码并使用gCloud控制台(也称为webapp)上传zip并定义了函数 converter 索引.js
    问题是我犯了这个错误

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

    我不明白我错过了什么。

    1 回复  |  直到 6 年前
        1
  •  1
  •   r4id4    6 年前

    我解决了这个问题。
    myAppProject ,而我应该已经压缩了其中包含的所有文件。在那之后它接受了 index.js 文件。