stylelint-config-standard-scss: Cannot resolve custom syntax module "postcss-scss"
I upgraded my Stylelint config to use Stylelint 14 and switched from stylelint-scss to stylelint-config-standard-scss, but now all the tests for my plugin failed with the following warning.
If I remove stylelint-config-standard-scss then everything works, but I would like to continue supporting sass files in my config.
Any ideas how I can resolve this?
Cannot resolve custom syntax module "postcss-scss". Check that module "postcss-scss" is available and spelled correctly.
at getCustomSyntax (node_modules/stylelint/lib/getPostcssResult.js:97:10)
at getPostcssResult (node_modules/stylelint/lib/getPostcssResult.js:41:5)
at lintSource (node_modules/stylelint/lib/lintSource.js:76:20)
at Function.standalone [as lint] (node_modules/stylelint/lib/standalone.js:132:26)
My PR can be seen here: https://github.com/spaceninja/stylelint-config-spaceninja/pull/171
The failing tests are here: https://github.com/spaceninja/stylelint-config-spaceninja/runs/3970823065?check_suite_focus=true
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 22 (8 by maintainers)
Same issue over here while updating to Stylelint 14.
Had the same issue in a yarn workspaces project. As mentioned the problem was caused by a module depending on PostCSS@7. I used
yarn why postcssto check and found the following lines:So I added the following to my root package.json:
After running
yarn installagain the issue was gone. Stylelint runs with no problem and also my create-react-app workspace still runs without problems.I’ve created PR stylelint/stylelint#5635 to clarify this error. If you install the PR version of Stylelint, you can see the real error:
You can resolve this error by installing PostCSS 8:
I’ve opened PR and issue in Stylelint repository.
I think this is related to Stylelint core custom syntax handling.
Stylelint tries to resolve custom syntax location (https://github.com/stylelint/stylelint/blob/main/lib/getPostcssResult.js#L95) but uses Node
requirealgorithm, so it search from that file upwards.If you have dependancy tree where
postcss-scssis 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.Easy fix should be to install
postcss-scssas your project dependancy so it can be placed inside rootnode_modules, but configs are meant to be self contained, otherwise we would have situation like long standing ESLint “bug”.@jeddy3 how can this be resolved? Should
requiretake some context? Or shouldpostcss-scssbe peer dependancy?