question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Next.js) Global CSS cannot be imported from within node_modules.

See original GitHub issue

I really enjoy the package, but it is not possible to be used with Next.js.

Description

When importing the package I receive following error message.

error - ./node_modules/rc-slider/assets/index.css
Global CSS cannot be imported from within node_modules.
Read more: https://err.sh/next.js/css-npm
Location: node_modules/react-jinke-music-player/es/index.js

It is quite discussed problem of Next.js. Is there any workaround with react-music-player? Some more info can be found on Next.js Github dedicated to this error.

Version

Using package version 4.16.5 with Next.js 9.5.1.

Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lijinke666commented, Aug 26, 2020

@emulienfou Your are right, in 4.17.1 version, I have already move 2 css files from index.js to index.less. you can try it 🥇

1reaction
emulienfoucommented, Aug 25, 2020

Hi @lijinke666 trying to use your package, however having the same issue with Next.js.

Is it possible for you to make some changes and load the 2 CSS files directly from your local less files instead of the index.js file of your package?

This will assure a compatibility with Next.js and also not using an outdated fork.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global CSS cannot be imported from within node_modules.
Try to import a CSS from a 3rd party lib. Expected behavior. To be able to import css. System information. OS: macOS; Chrome;...
Read more >
Next.js Global CSS cannot be imported from files other than ...
Since Next.js 9.2 global CSS must be imported in Custom <App> component. // pages/_app.js import '../global-styles/main.scss' export default ...
Read more >
Next.js: Global CSS cannot be imported from files other than ...
When migrating to Next.js 9+, I was running into an issue where I could not import global styles from any file other than...
Read more >
css-global | Next.js
An attempt to import Global CSS from a file other than pages/_app.js was made. Global CSS cannot be used in files other than...
Read more >
Global CSS cannot be imported from within node_modules
Global CSS cannot be imported from within node_modules. 2022.03.21 ... Read more: https://nextjs.org/docs/messages/css-npm Location: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found