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.

[experimental css] Getting error when importing global css inside _app

See original GitHub issue

Bug report

Describe the bug

I wanted to test experimental css implementation. Once I enabled it I got build error saying

Global CSS cannot be imported from files other than your Custom <App>. Please move all global CSS imports to src/pages/_app.tsx.

Only global peace of css (in fact only .css import in my app) is indeed defined inside _app.tsx

import 'normalize.css/normalize.css';

Hence I am not sure what this error means. Error trace doesn’t seem to point to any specific file either.

Only reason I can think of is if some other node_module is importing css internally?

System information

  • OS: macOS 10.15.2
  • Version of Next.js: 9.1.6

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Timercommented, Dec 27, 2019

I also just realized that we don’t tell you the file that’s importing the CSS file 🤕.

Opened a PR to fix that: #9850 (so you don’t have to guess)

0reactions
balazsorban44commented, Jan 30, 2022

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js Global CSS cannot be imported from files other than ...
So you have a global css that must be included on every single page, it has to be imported into the app file...
Read more >
Next.js: Global CSS cannot be imported from files other than ...
I would get the following error: Error. Global CSS cannot be imported from files other than your Custom <App\> . Please move all...
Read more >
[@next/storybook] - incorrectly imported css throws ... - GitHub
When a css file is imported in the wrong way, rather than displaying an error ... Please move all global CSS imports to...
Read more >
import - CSS: Cascading Style Sheets - MDN Web Docs
The @import CSS at-rule is used to import style rules from other valid stylesheets. An @import rule must be defined at the top...
Read more >
Styles & CSS - Astro Documentation
A common pattern in Astro is to import global CSS inside a Layout component. Be sure to import the Layout component before other...
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