-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error [ERR_REQUIRE_ESM]: lodash-es #8
Comments
Hi, have you solved the problem?:) |
Hey. Not who you where asking but I did open a PR with a fix requiring lodash instead of lodash-es Published it on npm with -cjs suffix on the name In case you still looking for a fix |
Same issue here, any updates ? :) |
Ok, so we have a problem. We (AlienFast) use an ESM only project downstream and the attempted switch from I'm not sure what to do for CJS users...if someone has an Idea please let me know! Without a good runtime solution, I'm going to remove the CJS release from our package. 😞 The only option I see at this point is to:
Thoughts? I am open for discussion - but this must work for ESM runtimes first and foremost. |
One alternative, so that this is both ESM and CJS compatible is to replace the If someone wants to PR the (deep) Any takers? |
I attempted the replacement 047c5a3 I'll try in ESM first (tests already pass in ESM so I assume it is all good) |
Woohoo! ESM confirm works for |
Hi, I had the same problem, thanks @rosskevin for attempting a fix, but I believe that this is not necessary. You can indeed keep the There are two possible solutions for this:
The latter fix helped in my case. Just rename your |
Damn, I thought I checked dot-prop for a cjs distributable! My haste when I thought I could do both! Interesting note on the vite config extensions. @pantajoe I have been using |
For me, it seems it's best practice to use Also, in my personal opinion, I'd say ESM is to be preferred to CJS and since vite has a "compatibility" option with mjs, there is no reason to support a cjs plugin 😅 |
I'm going to close this since there is an easy compatibility workaround mentioned by @pantajoe above:
Adding |
Hi,
i'm trying to use this plugin in my project and I've followed the instructions of the plugin.
I'm using
vite
version 4.0.1 and I've installed latest version ofvite-plugin-i18next-loader
which is 2.0.2.This is my
vite.config.ts
file:When I try to start my project with
vite
I get this error:failed to load config from
./vite.config.ts
error when starting dev server:
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/lodash-es/lodash.js from /node_modules/vite-plugin-i18next-loader/dist/index.cjs not supported.
Instead change the require of lodash.js in /node_modules/vite-plugin-i18next-loader/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object._require.extensions. [as .js] (file:///node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63157:17)
at Object. (/node_modules/vite-plugin-i18next-loader/dist/index.cjs:1:666)
at Object._require.extensions. [as .js] (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63157:17)
at Object. (/vite.config.ts:35:49)
at Object._require.extensions. [as .js] (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63154:24)
at loadConfigFromBundledFile (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63162:21)
at loadConfigFromFile (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:63020:34)
at async resolveConfig (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:62643:28)
at async createServer (file://node_modules/vite/dist/node/chunks/dep-5605cfa4.js:61943:20)
at async CAC. (file://node_modules/vite/dist/node/cli.js:707:24)
Thank you
The text was updated successfully, but these errors were encountered: