#Module not found: Can't resolve './globals.css' using symbolic Links
1 messages · Page 1 of 1 (latest)
Based on the information provided in the knowledge sources, I can offer some insights into your issue with resolving './globals.css' using symbolic links in Next.js. However, it's important to note that the knowledge sources don't provide a direct solution to your specific setup.
The error you're encountering suggests that Next.js is unable to resolve the './globals.css' file, which is likely due to the symbolic link not being properly recognized or followed.
Here are some potential approaches to address this issue:
-
Symlink Resolution:
Next.js and Webpack may have issues with resolving symlinks in certain configurations. You've already tried settingconfig.resolve.symlinks = falsein your webpack configuration, which is a good start, but it didn't resolve the issue. -
Absolute Imports:
Instead of using a relative import for your CSS file, you could try using an absolute import path. This might help Next.js locate the file correctly, regardless of symlinks. For example:import "~/DEV/PROJECT/src/app/globals.css"You may need to configure your
tsconfig.jsonorjsconfig.jsonto recognize the~alias. -
PostCSS Configuration:
If you're using a custom PostCSS configuration, ensure that it's properly set up to work with Next.js. According to this issue, there can be problems with PostCSS configs and Turbopack on Windows. -
Turbopack Considerations:
You're using the experimental Turbo feature. According to this issue, there can be problems with resolving modules when using Turbopack in development mode. You might want to try running without the Turbo feature to see if it resolves the issue.
-
Output File Tracing:
TheoutputFileTracingRootoption you commented out might actually be helpful. It allows you to specify the root directory for file tracing, which could help with resolving files outside the immediate project directory. You could try uncommenting and adjusting this option:outputFileTracingRoot: path.join(__dirname, ".."), -
Alternative Approach:
If none of the above solutions work, you might consider an alternative approach to sharing CSS between projects. For example, you could package the shared CSS as an npm module and import it in both projects, or use a monorepo setup with tools like Lerna or Nx that handle shared resources more robustly.