首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >多个云函数如何共享代码?

多个云函数如何共享代码?

提问于 2019-08-23 19:07:54
回答 1关注 0查看 496

Hi

我有三个云函数 Fun1,Fun2,Fun3, 其中通用部分代码放置在 Utils.js 里面

Utils.js

function Fun(){

return "Run here";

}

exports.Fun =Fun;

TFun1/index.js

var foo = require('../Utils.js');

module.exports.handler = function(event, context, callback) {

console.log(foo.Fun());

callback(null, 'hello world');

};

如果utils.js 放置在TFun1下面 (和index.js同级), 使用require('./Utils.js'); 则一切正常.

但是我想三个函数都使用utils.js内部的代码.

请问如何设置

谢谢

相关文章

相似问题

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