react-gauge-chart: Next.js issue Global CSS cannot be imported from within node_modules.
When installing and using the library in my next.js project, I got this issue:
./node_modules/react-gauge-chart/dist/GaugeChart/style.css
Global CSS cannot be imported from within node_modules.
Read more: https://err.sh/next.js/css-npm
Location: node_modules/react-gauge-chart/dist/GaugeChart/index.js
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
Decided to get a temporary fix. I have forked the repo and removed the css import from the module.
Next JS users may install the module using:
yarn add git+https://github.com/BossBele/react-gauge-chart.gitornpm install git+https://github.com/BossBele/react-gauge-chart.gitIn _app.js:
import "react-gauge-chart-nextjs-support/dist/GaugeChart/style.css";Use as “react-gauge-chart-nextjs-support”:
import GaugeChart from "react-gauge-chart-nextjs-support";This is only intended to be a temporary solution for nextJS users. Hopefully the maintainers of this project will fix this issue in the future. Meanwhile, we can’t stop coding!
@joeleduardo there is a workaround using
next-cssIn next.config.js:Then use next dynamic import with no ssr to import GaugeChart: