-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting "CSS Modules cannot be imported from within node_modules." with 4.0.0 and next 9.5.0 #95
Comments
I also have the same error, though without using local packages. Seems like providing any value to the array provided to Here is a repo to show the issue.
to
Will allow the project to build correctly. |
Looks like another issue with the cssloader issuer. The error disappears when changing the issuer to this.
So that the issuer contains the path of the running application in the |
Thank you lads for the report, I'll look into it as soon as possible and will try to add tests to prevent this regression from happening (but it's weird because we have a test for that, so I'll have to check what I did wrong) |
I cannot reproduce this error with my test setup here ( can you tell me more about the specificity of your setup? |
I could not reproduce it, but I could see indeed where the problem was in the webpack config, thanks for your help. I am going to draft a release, it would be great if someone can test it asap. Also, I still could not reproduce it locally, so I have no idea how to test this scenario, all feedback is welcome. |
With yarn workspaces, the symlinked local packages are hoisted to the root of the project, which means they don't match with the path of the running package directory.
Since your test project is not using yarn workspaces, the local package symlinks are placed inside the node_modules folder of your |
Thanks, I will add a test for yarn workspaces |
I have a potential fix available here: #96 Would you be able to test it before I release it to tell me if it solves your problem? |
confirm same bug with project https://github.com/slavb18/nextjscssmodules |
Should hopefully be fixed in 4.0.1, please share feedback if it works (or not)! |
Confirmed. 4.0.1 did the trick. Thanks for the fast turnaround! |
4.0.1 fixed it for my as well, thanks! |
I know this issue has long been laid to rest, but I just wanted to report that I was on 4.1.0 and had to roll back to 3.3.0 to get rid of this error. I am not using any local packages. I am on NextJS 9.4.4. |
Old versions are not supported and I recommend you to update to |
Also, see #146 |
Are you trying to transpile a local package or an npm package?
A local package
Describe the bug
I'm using Yarn workspaces and CSS Modules. After upgrading from
next-transpile-modules@3.3.0
andnext@9.4.4
tonext-transpile-modules@4.0.0
andnext@9.5.0
I'm getting the following error when running my application:From reading the source code, I see that CSS Modules are detected through some hacky string parsing. Maybe it's not working after the upgrade? Rolling back resolves the issue.
To Reproduce
My repo structure is as follows:
Then I import some components in
packageA
frompackageB
. Both use CSS Modules.Expected behavior
No errors. Same behavior as in v3.3.0
Setup
next-transpile-modules
version: 4.0.0npm
/yarn
version: yarn@1.22.4The text was updated successfully, but these errors were encountered: