Home >Web Front-end >CSS Tutorial >How Can I Fix 'Global CSS cannot be imported from files other than your Custom ' Errors in Next.js?
What's the Issue?
Next.js users may encounter an error stating, "Global CSS cannot be imported from files other than your Custom
Why Did This Error Occur?
This error may arise when using legacy CSS loaders such as @zeit/next-sass after upgrading to Next.js 9.2. Alternatively, incorrect configuration in next.config.js can also trigger the issue.
Solution
To resolve this issue, follow these steps:
Example: Moving Global CSS to _app.js
// pages/_app.js import '../global-styles/main.scss' export default function MyApp({ Component, pageProps }) { return <Component {...pageProps} /> }
Conclusion
By following these steps, you can resolve the "Global CSS cannot be imported from files other than your Custom
The above is the detailed content of How Can I Fix 'Global CSS cannot be imported from files other than your Custom ' Errors in Next.js?. For more information, please follow other related articles on the PHP Chinese website!