lucide: Import bug in Next.js (v13.4.13)
Prerequisites
- Version: 0.264.0
- Are you running from source/main: nop
- Are you using a released build: nop
- Operating system: Mac OS
- Bits: -
Step to reproduce
Import icon in a Next.js v13.4.13 (latest)
Actual behavior
I see an error when importing the icon.
Any message or error
Attempted import error: 'modularize-import-loader?name=CalendarDays&from=default&as=default&join=./icons/calendar-days!lucide-react' does not contain a default export (imported as 'CalendarDays').
It works well on v0.263.x, I suspect a bug in the new ESM export.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 29
- Comments: 34 (10 by maintainers)
@jguddas It would be great if Lucide React can add these aliases. Otherwise we’ll have to maintain a list in Next.js to optimize the imports.
There are more! like e.g. - Check & BadgeCheck…
Same for me,
Module not found: Can't resolve '/Users/jordan/project/node_modules/lucide-react/dist/cjs/icons/star'
Same problem
next: 13.4.13
lucide-react: 0.265.0
@abdelhameedhamdy I’m a bit surprised with your issue, after seeing your Nextjs Config. But just found out that the NextJS repo hardcoded some modularize imports for the
lucide-react
package, which are outdated with the changes inlucide-react@0.264.0
.See: https://github.com/vercel/next.js/blob/5ea372d6421614bfa10cc81ca5b3e71d8c06cf27/packages/next/src/server/config.ts#L686
So we need to update this list, but I’m not sure if this hardcoding is the best way if I’m honest. Some icons can be renamed and aliased. It is likely that this issue will happen again in the future.
If I import directly from the esm modules, I don’t get the error:
same here, seems to happen with all icons on next
13.4.12
too, downgrade to0.263.1
works fineI have just downgraded to
0.263.1
, and it works for now.error with 0.264.0 next 13.4.13
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module: ./components/ui/calendar.tsx ./app/page.tsx
next.config:
Created a fix: https://github.com/vercel/next.js/pull/53697
I am currently facing this issue with Next.js 13.4.13 and lucide-react version 0.264.0
My workaround: Downgraded lucide react to version 0.263.1 and it is working like expected.
+1
Packages version
next: "^13.4.13"
lucide-ract : "^0.265.0"
Getting Error while importing Icons
Error :
Downgrading lucide-react to 0.263.1 is working.
It will also break Sanity live previews and Serverless functions on Vercel.
Seems like
v0.264.0
and above are causing import problems.Adding my voice here. I would have never known the sweet spot is 0.263.1 without this discussion thread.
We should just generate those aliases as
./icons/{alias}.js
files, then we don’t need your workaround @shuding and we can drop #53483same for me here the list of icons not found:
lucide-react: ^0.264.0 Next.js (v13.4.13)