Hello,
I have an issue with my lambda function when I try to execute it.
{
"errorMessage": "Cannot find module 'babel-polyfill'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:417:25)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.
"__webpack_require__ (/var/task/auth.js:20:30)",
"Object.
"__webpack_require__ (/var/task/auth.js:20:30)",
"/var/task/auth.js:40:18",
"Object.
]
}
Webpack.config.js:
`const nodeExternals = require('webpack-node-externals');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
auth: ['babel-polyfill', './api/auth.js'],
handler: ['babel-polyfill', './api/handler.js'],
},
output: {
path: path.join(__dirname, './.webpack'),
filename: '[name].js',
libraryTarget: 'commonjs',
},
target: 'node',
devtool: 'source-map',
externals: [nodeExternals({
modulesFromFile: true,
})],
module: {
loaders: [
{
test: /.js$/,
loaders: ['babel'],
include: __dirname,
exclude: /node_modules/,
},
{
test: /.html$/,
loader: 'mustache',
},
],
},
};`
I had the same issue when running the babel example. Moving the babel-polyfill dependency from devDependencies to dependencies solved the issue for me. Not sure if the babel-runtime dependency is required.
@vladtamas Were you able to solve the issue? You also should upgrade to serverless-webpack 2.0.0.
@HyperBrain Yes. I forgot to set something in the configuration
@vladtamas What do you forgot to set?
I'm having the same issue. How did you guys resolve this?
Thanks
Most helpful comment
@vladtamas What do you forgot to set?