我正在尝试使用Weback构建一个简单的lambda nodejs函数hello world.
exports.handler = (event, context, callback) => {
callback(null, 'Hello from Lambda');
};
Run Code Online (Sandbox Code Playgroud)
此函数在lambda中工作,并在aws lambda配置页面中配置处理程序"index.handler".
Webpack为上面生成的代码不起作用.该函数抛出模块'index'上的错误"Handler'handler'".它看起来像模块成为反义词.
可以通过更新生成的代码使其工作,如下所示.
global.handler = (event, context, callback) => {
//async.map(['file1','file2','file3'], console.log, function(err, results){
// results is now an array of stats for each file
callback(null, 'Hello from Lambda');
//});
//add the following at the end.
exports.handler = global.handler;
Run Code Online (Sandbox Code Playgroud)
webpack.config.js如下.
var path = require('path');
module.exports = {
// Specify the entry point for our app.
entry: [
path.join(__dirname, '/src/autotag.js')
],
// Specify the output …Run Code Online (Sandbox Code Playgroud)