Skip to content
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

NextJS error caused by css imported by a dependency #22

Open
Couiljer opened this issue Jan 4, 2023 · 8 comments
Open

NextJS error caused by css imported by a dependency #22

Couiljer opened this issue Jan 4, 2023 · 8 comments

Comments

@Couiljer
Copy link

Couiljer commented Jan 4, 2023

Hi there,

Is there a way to use this package within a NextJS app ?
I cannot use it without receiving this error :

Global CSS cannot be imported from within node_modules. Read more: https://nextjs.org/docs/messages/css-npm Location: node_modules/react-leaflet-cluster/lib/index.js

thx

@airtonix
Copy link

airtonix commented Jan 7, 2023

same... needs to be fixed.

@jimping
Copy link

jimping commented Jan 25, 2023

Same here

@lukew-cogapp
Copy link

+1 :)

@lowkingshih
Copy link

vite import also

@lukew-cogapp
Copy link

Hi everyone,

If you update to Next 13.1, it now supports transpiling packages.

Here's a link to their docs.

Here's how I have used this in my next.config.js file:

module.exports = {
  reactStrictMode: true,
  transpilePackages: ["react-leaflet-cluster"],
};

Whilst I hope this gets fixed in the react-leaflet-cluster package, it's good Next has identified this as a useful workaround for older packages or those that haven't been updated yet.

@maosin77
Copy link

Yeah.. This is next issue. vercel/next.js#19936
They fixed it in next 13, but i would rather wait to upgrading next in my app for obvious reasons.
Do you guys plan to do something about it?

@JDuchniewicz
Copy link

I had to work around this problem as Next.js did not transpile this package so I copied over the library locally, removed .css files from the index.js and then imported them in my _app.js. Finally I changed the import to import from my local lib directory.

@korizki
Copy link

korizki commented Sep 19, 2023

I have same problem

Hi everyone,

If you update to Next 13.1, it now supports transpiling packages.

Here's a link to their docs.

Here's how I have used this in my next.config.js file:

module.exports = {
  reactStrictMode: true,
  transpilePackages: ["react-leaflet-cluster"],
};

Whilst I hope this gets fixed in the react-leaflet-cluster package, it's good Next has identified this as a useful workaround for older packages or those that haven't been updated yet.

I try this suggest,

  1. Updating next.config.js with code above,
  2. Update my next js application with next v.13.4 or you can update with "npm install next@latest"

And my problem was solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants