tabler / tabler-icons

A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
https://tabler.io/icons
MIT License
18.03k stars 898 forks source link

Module Import error with v3 #1032

Closed timheerwagen closed 6 months ago

timheerwagen commented 6 months ago

Problem

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