SyntaxError: The requested module '/node_modules/lodash/assignWith.js?v=85e602f8' does not provide an export named 'default' #14062
Replies: 4 comments 5 replies
-
repro: https://github.com/aladdin-add/repros/tree/vite-14062 |
Beta Was this translation helpful? Give feedback.
-
@aladdin-add - To use commonJS you would need a commonJS plugin The following actions on your reproduction repo will get it to work (I have already tried it) First install a commonjs plugin called @originjs/vite-plugin-commonjs npm i -D @originjs/vite-plugin-commonjs Then add a import { defineConfig } from 'vite';
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
export default defineConfig({
plugins: [
viteCommonjs(),
]
}); And your problem would be solved. PS: Feel free to mark this comment as the answer if it solves your issue. |
Beta Was this translation helpful? Give feedback.
-
In your reproduction, import { defineConfig } from 'vite'
export default defineConfig({
optimizeDeps: {
include: ['foo/mod.js']
}
}) Maybe you need to add |
Beta Was this translation helpful? Give feedback.
-
Is it still true that Vite needs a plugin to support CommonJS? And if so, does the plugin need to be enabled manually, or is it active by default? The docs seem to imply that CommonJS is supported, under Dependency Pre-Bundling:
|
Beta Was this translation helpful? Give feedback.
-
help wanted! 🙌
I was using vite v4 to develop a react app. It was working before, but after upgrading a certain dependency it started reporting this error, and upgrade to latest(v4.4.9) does not help.
// the lodash was installed(cjs).
vite config:
I was under the impression that it's allowed to import cjs in esm module (even in vite), but for some reason this one doesn't load successfully.
Beta Was this translation helpful? Give feedback.
All reactions