-
Notifications
You must be signed in to change notification settings - Fork 217
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
deepmerge_1.default) is not a function (No Webpack) #255
Comments
I have the same issue when using Using import deepmerge from 'deepmerge';
// ...
deepmerge(car, body, mergeOptions); Is throwing the following error Any update on this? |
@douglasg14b one common way to fix this if not already done is to import the library like this:
If your code is compiled somehow somewhere, it will basically tell your compiler to expect a CommonJS Hope it helped. |
This module is CJS-only, see #250 . As far as I know you can do this in ESM files to import CJS modules, but this only works in NodeJS, not in the browser for example: import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const deepmerge = require('deepmerge'); // Function Vice versa, in CJS files you can use dynamic imports to asynchronously import ESM, just FYI. If you have to use this library in the browser and don't want to use bundlers to transform it and complicate your local dev setup that way, you can use my ESM fork of this lib: https://www.npmjs.com/package/@bundled-es-modules/deepmerge (Github repo) |
And ran inside a Jest test, results in:
No webpack, vite, or anything else involved.
The text was updated successfully, but these errors were encountered: