首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Google Cloud Functions中的Node Express js

Google Cloud Functions中的Node Express js
EN

Stack Overflow用户
提问于 2018-05-31 18:10:03
回答 1查看 934关注 0票数 1

我已经创建了一个expressjs应用程序,并且正在尝试将其部署到Google Cloud Functions中。

我自己开发了这个应用程序,然后按照这个guide将其附加到gCloud function服务。基本上,我在项目的根目录中创建了一个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)上传了压缩文件,并定义了函数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.

我不明白我错过了什么。

EN

回答 1

Stack Overflow用户

发布于 2018-05-31 18:59:07

我发现了问题所在。

我压缩了myAppProject,而我应该压缩它包含的所有文件。之后,它接受index.js文件。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50621793

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档