You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Next.js project with "type": "module" I try to import an icon from @tabler/icons-react and i get following error:
⨯ ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'C:\...\node_modules\@tabler\icons-react\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///C:/.../node_modules/@tabler/icons-react/dist/cjs/tabler-icons-react.js:10:13
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15) {
}
"@tabler/icons-react": "^3.0.0"
Workaround
Put @tabler/icons-react into transpilePackages inside next.config.js
The text was updated successfully, but these errors were encountered:
Problem
In a
Next.js
project with"type": "module"
I try to import an icon from@tabler/icons-react
and i get following error:"@tabler/icons-react": "^3.0.0"
Workaround
Put
@tabler/icons-react
intotranspilePackages
insidenext.config.js
The text was updated successfully, but these errors were encountered: