Serverless-webpack: Cannot find module 'babel-polyfill'

Created on 14 May 2017  路  5Comments  路  Source: serverless-heaven/serverless-webpack

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. (/var/task/auth.js:55:19)",
"__webpack_require__ (/var/task/auth.js:20:30)",
"Object. (/var/task/auth.js:47:2)",
"__webpack_require__ (/var/task/auth.js:20:30)",
"/var/task/auth.js:40:18",
"Object. (/var/task/auth.js:43:10)"
]
}

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',
},
],
},
};`

Most helpful comment

@vladtamas What do you forgot to set?

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tommedema picture tommedema  路  4Comments

hassankhan picture hassankhan  路  3Comments

onhate picture onhate  路  5Comments

bericp1 picture bericp1  路  5Comments

bebbi picture bebbi  路  3Comments