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.

Global CSS cannot be imported from within node_modules.

See original GitHub issue

I got this error after installing this package:

Failed to compile
./node_modules/tippy.js/animations/scale.css
Global CSS cannot be imported from within node_modules.
Read more: https://err.sh/next.js/css-npm
Location: node_modules/react-wordcloud/dist/index.module.js #

Not quite sure how to fix it. Can you please help taking a look?

Thank you for the work!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
chrisrzhoucommented, Apr 21, 2020

Hey guys, this issue seems specific to next. Although, ideally I should decouple the CSS from the JS package and have users explicitly import the CSS file. However, since the version has been shipped with included CSS in the past, I want to avoid introducing breaking changes just because of this.

I’ve never used next but after 30min of digging, I found out how to fix this thanks to your repro @xiqi. Here’s the fix:

The next.config.js that fixes it is:

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

global.navigator = () => null;

if (typeof require !== 'undefined') {
  require.extensions['.less'] = () => {};
  require.extensions['.css'] = file => {};
}

module.exports = withCSS({});

It seems that the person who filed the issue has asked for more formal support of CSS by default in an RFC, but hopefully this is a short-term fix for next-related builds. Let me know if the issue persists and reopen the issue.

0reactions
bfeistercommented, Mar 12, 2021

Actually, I take that back, it’s broken for me @chrisrzhou… Works when I run NODE_ENV=development next dev -p 8025 but breaks when I run next build, same as what @suino reported above ☝️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global CSS cannot be imported from within node_modules.
I can't import a css file from a node_modules 3rd party library as described here (https://nextjs.org/docs/basic-features/built-in-css-support# ...
Read more >
Next.js Global CSS cannot be imported from files other than ...
Hey, I created and move the main. · @IndustryDesigns, try to use node-sass instead of @zeit/next-sass , I just tested it and updated...
Read more >
Global CSS cannot be imported from within node_modules
18 Day 11 77. Combinations Given two integers n and k, return all possible combinations of k numbers out of the range [1,...
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 >
Next.js Global CSS cannot be imported from files other than ...
CSS : Next.js Global CSS cannot be imported from files other than your Custom App [ Beautify Your Computer ...
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