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
Fix custom syntax module path not properly resolving #5632
Comments
This is likely caused by an incompatible version of PostCSS in the tree. (The error will be clearer in the next release). You can use Root
|
Thank you for the explanation, but I found that for me the only reason for the wrong version of
I think than the |
It's incompatible versions of |
This doesn't seem related only to an incompatible version of
Updating
Only then would |
After updating |
After updating
So all the uses were pointing at the latest 8.3.11 version, AFAICT, but that wasn't sufficient to fix the error. |
Thanks. Let's reopen this as there seems to be more going on than incompatible versions. Does anyone have any thoughts, e.g. is #5633 the answer here? |
@fwextensions Is it possible to share your reproduction code to raise the error? |
My thinking is that this should be the answer since it follows same logic for resolving 3rd-party dependencies as for presets and plugins. If it doesn’t work there, Stylelint maybe has some other issues with resolving algorithm. So, maybe we should reopen that PR? |
FYI. Here are code resolving Lines 360 to 362 in f218b59
stylelint/lib/getPostcssResult.js Lines 40 to 42 in f218b59
stylelint/lib/getPostcssResult.js Lines 90 to 134 in f218b59
|
@ybiquitous as mentioned in my original post, problem is probably in using just the standard Node |
@niksy Thank you for providing more information. It seems better to use our |
@ybiquitous the code is in a private repo that somebody else built. A couple of scripts in its package.json referred to One thing to note is that this project has only |
@fwextensions Thanks for the response. I'd like to get a small reproduction code if possible... 😅 |
Same issue over here while updating to stylelint v14 💥 |
I solved this in Yarn 2+ by adding postcss and postcss-scss as direct devDependencies to my project, and adding this to
|
I got a small reproduction as below. Now I am looking into the error.
{
"dependencies": {
"postcss": "7.0.39",
"stylelint": "14.1.0",
"stylelint-config-recommended-scss": "5.0.1"
},
"scripts": {
"lint": "stylelint *.scss"
},
"stylelint": {
"extends": "stylelint-config-recommended-scss"
}
}
a {} Run: $ node -v ; npm -v
v16.13.0
8.1.3
$ npm i
...
$ npm run lint
> lint
> stylelint *.scss
Error: Cannot resolve custom syntax module "postcss-scss". Check that module "postcss-scss" is available and spelled correctly.
at getCustomSyntax (/Users/koba/tmp/foo/node_modules/stylelint/lib/getPostcssResult.js:99:11)
at getPostcssResult (/Users/koba/tmp/foo/node_modules/stylelint/lib/getPostcssResult.js:41:5)
at lintSource (/Users/koba/tmp/foo/node_modules/stylelint/lib/lintSource.js:76:20)
at async /Users/koba/tmp/foo/node_modules/stylelint/lib/standalone.js:218:27
at async Promise.all (index 0)
at async standalone (/Users/koba/tmp/foo/node_modules/stylelint/lib/standalone.js:257:22) $ npm ls postcss
foo@ /Users/koba/tmp/foo
├── postcss@7.0.39
├─┬ stylelint-config-recommended-scss@5.0.1
│ └─┬ postcss-scss@4.0.2
│ └── postcss@8.3.11
└─┬ stylelint@14.1.0
├─┬ postcss-safe-parser@6.0.0
│ └── postcss@8.3.11 deduped
└── postcss@8.3.11 EDIT: For coexistence of different versions of PostCSS, $ find node_modules -type d -name postcss-scss
node_modules/stylelint-config-recommended-scss/node_modules/postcss-scss $ node -pe "require('postcss-scss')"
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'postcss-scss'
Require stack:
- /Users/koba/tmp/foo/[eval]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at [eval]:1:1
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:81:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:80:60) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/koba/tmp/foo/[eval]' ]
} $ node -pe "require('stylelint-config-recommended-scss/node_modules/postcss-scss')"
{ parse: [Function: scssParse], stringify: [Function: scssStringify] } |
Hey, I'm trying to use stylelint with CRA and am having the same issue. I'm fine installing edit: i know i could switch to cra 5, but id rather stick with 4 as 5 is still an alpha release |
As I investigated on #5632 (comment), the Node.js This seems a temporary problem until the PostCSS community finishes migrating to PostCSS 8, so I think now there are the following options:
What do you think? |
Even though I'm just a user, I'd say the first option is the best for this case. Since it's a temporary issue, might as well take the easier approach. There's not that many people that are affected by this, and anyone writing/using a shareable config that does need to do this could easily fix it given there's only 1 line to change. |
Welp seems like I'm not just a user anymore lol |
@ybiquitous Thank you very much for the investigation! I agree that the first approach is best. I've opened the pull request to update our docs. @tom-ricci Thanks for opening the issue and pull request in the scss package. Even though I'm not usually active in that repo, I've merged and released as it's related to the |
As per stylelint-scss/stylelint-config-standard-scss#2, custom syntax module path is not properly resolved.
Stylelint tries to resolve custom syntax location (stylelint/stylelint@
main
/lib/getPostcssResult.js#L95) but uses Noderequire
algorithm, so it search from that file upwards.If you have dependancy tree where
postcss-scss
is not in one of the root directories, but is nested inside this config’snode_modules
(it happens if you have different versions of same package), path resolution fails.None, it’s related to core functionality
Even empty SCSS file would do.
But
postcss-scss
shouldn’t be installed inside rootnode_modules
.14.0.0
stylelint "**/*.scss"
Yes, it's related to SCSS custom syntax.
Should return at least error/warning related to style code or exit code
0
if everything is OK.The text was updated successfully, but these errors were encountered: