0xgoku
0xgoku

Reputation: 518

Global CSS cannot be imported from files other than your Custom <App>

I'm getting the following error:

./styles/globals.scss
Global CSS cannot be imported from files other than your Custom <App>. 
Due to the Global nature of stylesheets, and to avoid conflicts, 
Please move all first-party global CSS imports to pages/_app.js. 
Or convert the import to Component-Level CSS (CSS Modules).

Read more: https://nextjs.org/docs/messages/css-global
Location: pages/_app.tsx

enter image description here

And this error disappears when I commented out the following lines in the _app.tsx

// import "@styles/globals.scss";

enter image description here

But noticed that the stylesheet isn't being applied. Any ideas how to fix this?

Here's the output of my npm list

 $ npm list --depth 0
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
 $ npm list -g --depth 0
/Users/glaksmono/.nvm/versions/node/v16.8.0/lib
└── [email protected]

Upvotes: 4

Views: 7779

Answers (2)

amroyer
amroyer

Reputation: 1

I was having the same issue, and I think the problem was that all of my code was being SmartSynced to Dropbox. As soon as I ran create-next-app in a folder that wasn't aliased into the Dropbox directory, everything worked fine. My suspicion is that Node/Webpack was seeing the wrong path because of the aliasing and that caused the error.

Upvotes: 0

Brayden W
Brayden W

Reputation: 128

apparently there is a breaking change with [email protected] on windows. Downgrade to [email protected] to fix this issue.

Source: https://stackoverflow.com/a/68992114/12198209

Upvotes: 4

Related Questions