False negative for "Global CSS cannot be imported from within node_modules" warning
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
Binaries:
Node: 14.19.3
npm: 6.14.17
Yarn: 1.22.15
pnpm: 6.11.0
Relevant packages:
next: 12.2.5-canary.5
eslint-config-next: 12.2.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
n/a
How are you deploying your application? (if relevant)
n/a
Describe the Bug
Our components library (https://github.com/cloudscape-design/components) exports scoped styles, but we still get the warning:
./node_modules/@cloudscape-design/components/app-layout/content-wrapper/styles.scoped.css
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/@cloudscape-design/components/app-layout/content-wrapper/styles.css.js
We use zero-config CSS scoping (e.g. the files published on npm are already scoped), but next.js still claims we are doing something wrong (do we?)
Expected Behavior
The project starts successfully with the default next config
Link to reproduction
https://github.com/just-boris/cloudscape-nextjs
To Reproduce
Currently next.config.js
contains a workaround: https://github.com/just-boris/cloudscape-nextjs/blob/main/next.config.js#L8
To reproduce the issue, you need to replace module.exports = withTM(nextConfig);
with module.exports = nextConfig;
Issue Analytics
- State:
- Created a year ago
- Reactions:8
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Next.js Global CSS cannot be imported from files other than ...
js stops complaining when your file has module in naming, e.g., changing import '../global-styles/main.scss'; to import '../global-styles/main.
Read more >global css cannot be imported from within node_modules ...
ts import "/node_modules/primeng/resources/primeng.css"; they are thrown out by webpack because sideEffects is set to "false" in primeng/package.json. When they ...
Read more >Features | Vite
Rewrite the imports to valid URLs like /node_modules/.vite/deps/my-dep.js?v=f3sf2ebd so that the browser can import them properly. Dependencies are Strongly ...
Read more >Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... imports inside externalized packages (by default, node_modules ).
Read more >Global CSS cannot be imported from within node_modules
Global CSS cannot be imported from within node_modules. 2022.03.21 ./node_modules/antd-mobile/es/components/action-sheet/action-sheet.css Global CSS cannot ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
🚨 Bumping up this bug 🐛
https://github.com/uiwjs/next-remove-imports