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
Unocss not working in NextJS 14.2.3 version #3768
Comments
I have the same issue, downgrade |
#3380 changed the behavior of how CJS module is resolved. I took a quick look at it but I don't know how we could fix/restore the previous behavior. Similar issue: #3724. They solved the issue by moving the config file to ESM format but I don't think this is possible for Next.js. If I remember correctly Next.js was very strict about PostCSS config format. |
It looks like next.js@^14.2.0-canary.25 already supports PostCSS ESM Config. vercel/next.js#34448 (comment) It seems like plugins still need to be provided as strings though. I'll look into that later. |
It looks like Next.js is still trying to An error occurred in `next/font`.
TypeError: require(...) is not a function
at /workspaces/sandbox/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.5_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:62:63
at plugin (/workspaces/sandbox/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.5_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:30:44)
at Processor.normalize (/workspaces/sandbox/node_modules/.pnpm/postcss@8.4.31/node_modules/postcss/lib/processor.js:18:13)
at new Processor (/workspaces/sandbox/node_modules/.pnpm/postcss@8.4.31/node_modules/postcss/lib/processor.js:11:25)
at postcss (/workspaces/sandbox/node_modules/.pnpm/postcss@8.4.31/node_modules/postcss/lib/postcss.js:26:10)
at /workspaces/sandbox/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.5_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/config/blocks/css/index.js:127:37
at async /workspaces/sandbox/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.5_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js:86:33
at async Span.traceAsyncFn (/workspaces/sandbox/node_modules/.pnpm/next@14.2.1_@babel+core@7.24.5_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/trace/trace.js:154:20) |
The problem is the default export in cjs, we need to use |
This worked for me, thanks a lot! |
UnoCSS version
0.59.4
Describe the bug
I was going to prefer unocss for a brand new start in nextjs, I created a next-app and followed the same steps to install unocss:
unocss nextjs example
But the situation is that I could not solve this error even though I did the same steps 2 times:
note: Removing the global.css file fixes the error, so I think there is a problem in @ import or @ unocss in global css.
Reproduction
https://codesandbox.io/p/devbox/exciting-haslett-w8dny8?file=%2Fpackage.json%3A14%2C23
System Info
Windows 10
NodeJS > 20
Next 14.2.3
Validations
The text was updated successfully, but these errors were encountered: