vue3-gettext
vue3-gettext copied to clipboard
Recent issue when extract or compile : Error [ERR_REQUIRE_ESM]: require() of ES Module
> vue-gettext-compile
/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/loaders.js:32
throw error;
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/wilhemarnoldy/Developpements/Berlioz/gettext.config.js from /Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/loaders.js not supported.
gettext.config.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename gettext.config.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/wilhemarnoldy/Developpements/Berlioz/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at module.exports (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/import-fresh/index.js:32:59)
at loadJs (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/loaders.js:16:18)
at ExplorerSync.loadFileContentSync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:84:26)
at ExplorerSync.createCosmiconfigResultSync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:89:30)
at ExplorerSync.loadSearchPlaceSync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:70:25)
at ExplorerSync.searchDirectorySync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:55:32)
at run (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:35:27)
at cacheWrapperSync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/cacheWrapper.js:28:18)
at ExplorerSync.searchFromDirectorySync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:47:49)
at ExplorerSync.searchSync (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/cosmiconfig/dist/ExplorerSync.js:27:25)
at loadConfig (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/vue3-gettext/dist/bin/gettext_compile.js:105:30)
at Object.<anonymous> (/Users/wilhemarnoldy/Developpements/Berlioz/node_modules/vue3-gettext/dist/bin/gettext_compile.js:144:14) {
code: 'ERR_REQUIRE_ESM'
}
Package version is : 2.4.0
Thanks a lot
@Wewill thanks for reporting this. i was no aware that this was an issue, but I'm working on esm-related stuff in #41 that should fix this aswell.
i don't quite remember how I set up cosmiconfig (and i'll replace it soon), but here are 2 ideas you could try in the meantime (I have no idea if any of this will work):
- rename the file to
gettext.config.cjs
- rename the file to
gettext.config.json
and write the config as json instead of js
Thanks a lot @lzurbriggen for your quick reply.
Renaming the file to gettext.config.cjs
is quickly fixing the issue !
Thanks again !
Can we use gettext.config.ts
after #41 ~
so that we can use code hint
export default defineGettextConfig({
...
})
@youthlin i will try to implement a ts-node based loader to enable this. i don't have a lot of time at the moment, so all of that will probably take a while.