Next.js Discord

Discord Forum

Weird serverless errors

Unanswered
Northeast Congo Lion posted this in #help-forum
Open in Discord
Avatar
Northeast Congo LionOP
Hi!
I am fighting with this error since this morning on a serverless function in the api directory:
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/packages/themes/scout/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///var/task/packages/themes/scout/api/custom-form.js:5:23
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/var/task/packages/themes/scout/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///var/task/packages/themes/scout/api/custom-form.js:5:23
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Error: Runtime exited with error: exit status 1
Runtime.ExitError


What I don't understand is the function just works in development how come in production is completely messed up?

0 Replies