react-gauge-chart icon indicating copy to clipboard operation
react-gauge-chart copied to clipboard

Next.js issue Global CSS cannot be imported from within node_modules.

Open gcaggia opened this issue 5 years ago • 16 comments

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

gcaggia avatar Jun 05 '20 06:06 gcaggia

Got the same issue

BossBele avatar Jun 16 '20 13:06 BossBele

I've got the same issue. I tried npm install @types/react-gauge-chart and it worked!

sunshine9249 avatar Jun 21 '20 06:06 sunshine9249

I've got the same issue. I tried npm install @types/react-gauge-chart and it worked!

Did not work for me

BossBele avatar Jun 22 '20 16:06 BossBele

Same - not working for me

shamoons avatar Jul 17 '20 17:07 shamoons

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.git or npm install git+https://github.com/BossBele/react-gauge-chart.git

In _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!

BossBele avatar Jul 27 '20 12:07 BossBele

@BossBele thanks

younes6970 avatar Sep 06 '20 12:09 younes6970

@BossBele thanks

@younes6970 You're welcome!

BossBele avatar Sep 06 '20 13:09 BossBele

Hi i tried your solution but is not working @@BossBele.... looks like deleting this line the problem is solved

https://github.com/BossBele/react-gauge-chart/blob/master/dist/GaugeChart/index.js#L14

joeleduardo avatar Nov 12 '20 15:11 joeleduardo

@joeleduardo It was commented earlier.. Looks like the recent push was not efficient. It is fixed now

BossBele avatar Nov 12 '20 17:11 BossBele

Do you know when will be merged your changes? (to the main repo) @BossBele

joeleduardo avatar Nov 13 '20 12:11 joeleduardo

Not exactly Sir @joeleduardo but It is in the process. However, there is another workaround (using next-css) I am currently verifying. If it works, there won't be a need for the Pull Request to be merged. I will post here my findings.

BossBele avatar Nov 13 '20 15:11 BossBele

@joeleduardo there is a workaround using next-css In next.config.js:

const withCSS = require("@zeit/next-css");

module.exports = withCSS();

Then use next dynamic import with no ssr to import GaugeChart:

const GaugeChart = dynamic(() => import("react-gauge-chart"), { ssr: false });

export default function MyComponent(props) {
  return (
                <div>
                  <GaugeChart
                    id="gauge-chart1"
                    arcsLength={[0.2, 0.3, 0.5]}
                    colors={["#EA4228", "#F5CD19", "#5BE12C"]}
                    percent={0.1}
                  />
                </div>
    )
}

BossBele avatar Nov 13 '20 16:11 BossBele

@BossBele Your pull request is merged with master now

Martin36 avatar Nov 20 '20 18:11 Martin36

@BossBele i believe that @zeit/next-css will be deprecated

joeleduardo avatar Nov 23 '20 14:11 joeleduardo

@joeleduardo Oh, okay

BossBele avatar Nov 23 '20 14:11 BossBele

https://github.com/uiwjs/react-md-editor/issues/52#issuecomment-848969341

next-remove-imports Perfect solution.

@joeleduardo @BossBele

jaywcjlove avatar May 28 '21 02:05 jaywcjlove