Closed dcheglakov closed 1 year ago
Fixed. The problem is that mjml was added as a dev dependency, moved to dependencies and everything worked. Apologies.
Hi, i had the same thing happening to me for puppeteer
. So, for reference and hoping some search engine picks this up:
I was:
@sveltejs/adapter-node
ReferenceError: require is not defined in ES module scope, you can use import instead
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
Check that you have not accidentally added a dependency as devDependency in package.json.
Hello everyone!
I've spent 1.5days to workaround in the context of the directus extensions build system
I got the same error, and after investigation found that the source of the error was html-minifier
package. I've tried all options (mjml-browser, mrml (wasm bindings)).
And on this issue I found this magic lines
"overrides": {
"html-minifier": "npm:html-minifier-terser@7.1.0"
}
I've added it to the package JSON and everything worked!!!
Describe the bug
When trying to import
mjml
in node enviroment in production I get a 500 error and with this errorrequire is not defined in ES module scope, you can use import instead
I've checked
mjml
on publint no errors, all good.Reproduction
A reproduction of the issue can be found at https://github.com/dcheglakov/sveltekit-mjml-import
To reproduce:
pnpm i
ornpm i
pnpm dev
- everything is finepnpm build
thenpnpm preview
- everything is fineHOST=127.0.0.1 PORT=4000 node build
- 500 error, check logs for more infoLogs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response