3 ms·
Not having much luck running non-strict Node.JS classic scripts in Bun using CommonJS/require. Errors about strict mode despite not using "use strict";. Is ther
by jwocky 3y ago
Not having much luck running non-strict Node.JS classic scripts in Bun using CommonJS/require. Errors about strict mode despite not using "use strict";. Is there a flag to allow such scripts to run?
- Jarred 3y agoTry referencing `exports` or `module` in your code. That will automatically make it use CommonJS which doesn't have strict mode by default.
- eyelidlessness 3y agoBun internally treats most CJS modules as ESM, mapping require() calls to synchronous import() etc. And ESM is always strict mode, so that might be the issue?
- Jarred 3y agoThis used to be true, but now it transpiles to CommonJS with sloppy mode by default when "exports" or "module" is used
- rfalon 3y agoBun is not able to run non-strict javascript and there is no documentation that suggests it will be supported. No choice other than running Node.JS for this.