serverless-bundle
serverless-bundle copied to clipboard
Failing with `ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead`
Hello,
my lambda failing with the following error. Do I need to use import instead of require everywhere with serverless-bundle?
"ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: 53521"
Thank you and best,
+1 on this. Any solution ?
+1 on this. Any solution?
One solution which worked for me is to import / export all the direct imports (which are in the same folder or above for example) using ESM import / export. Also the handler needs to be exported either with export default const .... than also the handler needs to be named default in the serverless.yml or doing a const handlerName and then on the bottom export { handlerName } than the handler name can be the same in the serverless.yml.
Hope this helps.
Any solution on this?
I'm also getting this error, in my case I'm using prisma4 with serverless-bundle, and my runtime is Node 16
Use esbuild-loader
Add following option to serverless.yml file
custom:
bundle:
esbuild: true