Closed
Description
OK so I am writing this so other people dont waste hours like me.
Issue
Your function works when you manually tested and with simple express server, but throws errors in both serve
and build
modes of netlify-lambda.
Possible Cause
It may be that one of the dependencies has a browser
field defined in its package.json
(could be indirect dep), which in most cases is not compatible with Node, but Webpack by default prefers it over main
or module
definitions.
Solution
Create a webpack.functions.js
file in with a modified resolver, so it skips the browser bundle
module.exports = {
resolve: {
mainFields: ['module', 'main']
}
}
Then run your command
netlify-lambda serve functions --config ./webpack.functions.js
Metadata
Metadata
Assignees
Labels
No labels