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
Cannot resolve custom syntax module "postcss-scss" #2
Comments
I have the same error. |
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 If you have dependancy tree where Easy fix should be to install @jeddy3 how can this be resolved? Should |
I still get the same error even with postcss-scss defined as a dev dependency (and its at the root of node_modules): "devDependencies": {
"@babel/core": "7.15.8",
"@babel/preset-env": "7.15.8",
"@babel/preset-typescript": "7.15.0",
"@digitalroute/cz-conventional-changelog-for-jira": "6.6.0",
"@fortawesome/free-solid-svg-icons": "5.15.4",
"@nuxt/types": "2.15.8",
"@nuxt/typescript-build": "2.1.0",
"@nuxtjs/eslint-config-typescript": "6.0.1",
"@nuxtjs/eslint-module": "3.0.2",
"@nuxtjs/fontawesome": "1.1.2",
"@nuxtjs/stylelint-module": "4.0.0",
"@semantic-release/git": "10.0.0",
"@storybook/addon-actions": "6.3.12",
"@storybook/addon-essentials": "6.3.12",
"@storybook/addon-knobs": "6.3.1",
"@storybook/addon-links": "6.3.12",
"@storybook/addon-postcss": "2.0.0",
"@storybook/vue": "6.3.12",
"@types/aws-lambda": "8.10.84",
"@types/dompurify": "2.3.1",
"@types/jest": "27.0.2",
"@vue/test-utils": "1.2.2",
"autoprefixer": "10.3.7",
"axios-mock-adapter": "1.20.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "27.3.1",
"babel-loader": "8.2.3",
"css-loader": "5.2.7",
"cz-conventional-changelog": "3.3.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-nuxt": "2.0.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-vue": "7.20.0",
"file-loader": "6.2.0",
"generate-template-files": "3.2.0",
"graphql": "15.6.1",
"graphql-tag": "2.12.5",
"jest": "27.3.1",
"jest-transform-graphql": "2.1.0",
"mini-css-extract-plugin": "1.6.2",
"multi-semantic-release": "2.9.1",
"node-sass": "6.0.1",
"oao": "2.0.2",
"postcss-scss": "^4.0.1",
"prettier": "2.4.1",
"resolve-url-loader": "4.0.0",
"sass-loader": "10.2.0",
"semantic-release": "18.0.0",
"serverless-offline": "8.2.0",
"serverless-plugin-monorepo": "0.10.0",
"serverless-s3-deploy": "0.10.1",
"stylelint": "14.0.0",
"stylelint-config-prettier": "9.0.3",
"stylelint-config-standard": "23.0.0",
"stylelint-config-standard-scss": "^2.0.0",
"terser-webpack-plugin": "4.2.3",
"ts-jest": "27.0.7",
"ts-loader": "8.3.0",
"typescript": "4.4.4",
"vue-jest": "3.0.7",
"vue-loader": "15.9.8",
"vue-server-renderer": "2.6.14",
"vue-template-compiler": "2.6.14",
"webpack": "4.46.0",
"webpack-bundle-analyzer": "4.5.0",
"webpack-cli": "4.9.1",
"webpack-graphql-loader": "1.0.2"
}, |
Hm, that’s weird. Can you provide directory listing of your |
Should clarify this is a yarn workspaces project, but stylelint is installed and executed from the root of the project, not inside a specific workspace |
Can you apply changes from this commit to your local Stylelint? I’m preparing issue and PR for Stylelint and when I apply this change everything works. |
> yarn run stylelint **/*.{css,sass,scss}
Error: Cannot resolve custom syntax module "/home/rich/Workspace/rv-nuxt-monorepo/node_modules/postcss-scss/lib/scss-syntax.js". Check that module "/home/rich/Workspace/rv-nuxt-monorepo/node_modules/postcss-scss/lib/scss-syntax.js" is available and spelled correctly.
at getCustomSyntax (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/getPostcssResult.js:97:10)
at getPostcssResult (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/getPostcssResult.js:41:5)
at lintSource (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/lintSource.js:76:20)
at async /home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/standalone.js:218:27
at async Promise.all (index 5)
at async standalone (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/standalone.js:257:22)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. File does exist though: > cat "/home/rich/Workspace/rv-nuxt-monorepo/node_modules/postcss-scss/lib/scss-syntax.js"
let stringify = require('./scss-stringify')
let parse = require('./scss-parse')
module.exports = { parse, stringify } |
And what about running with npm instead of Yarn? |
Same: > npx stylelint **/*.scss
Error: Cannot resolve custom syntax module "/home/rich/Workspace/rv-nuxt-monorepo/node_modules/postcss-scss/lib/scss-syntax.js". Check that module "/home/rich/Workspace/rv-nuxt-monorepo/node_modules/postcss-scss/lib/scss-syntax.js" is available and spelled correctly.
at getCustomSyntax (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/getPostcssResult.js:97:10)
at getPostcssResult (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/getPostcssResult.js:41:5)
at lintSource (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/lintSource.js:76:20)
at async /home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/standalone.js:218:27
at async Promise.all (index 1)
at async standalone (/home/rich/Workspace/rv-nuxt-monorepo/node_modules/stylelint/lib/standalone.js:257:22) > npm -v
6.14.15
> node -v
v14.17.6 |
That’s really weird… Can you log error inside I’ve just tried running tests with Yarn and everything works OK. try {
resolved = require(customSyntax);
} catch (error) {
console.log(error);
throw new Error(
`Cannot resolve custom syntax module "${customSyntax}". Check that module "${customSyntax}" is available and spelled correctly.`
);
} |
It seems the issue is that I have other dependencies which require postcss 7. Heres a repo with the bare minimum set up to manifest the problem: https://github.com/middric/stylelint-test/ Remove this line https://github.com/middric/stylelint-test/blob/master/package.json#L12 and everything works |
Ah, yes, and error is probably something not related to unresolved path, but rather something with syntax and API changes in PostCSS 8. |
Hi there, now I am looking into this problem. Maybe, the cause may be requiring an old PostCSS module
EDIT: The dependencies above is on spaceninja/stylelint-config-spaceninja#171 |
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: $ git clone https://github.com/spaceninja/stylelint-config-spaceninja.git
$ cd stylelint-config-spaceninja
$ git switch renovate/stylelint-14.x
$ yarn add --dev github:stylelint/stylelint#better-error-handling-for-module-not-found
$ yarn test
...
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (node_modules/postcss-scss/lib/nested-declaration.js:3:33)
at Object.<anonymous> (node_modules/postcss-scss/lib/scss-parser.js:4:25)
... You can resolve this error by installing PostCSS 8: $ yarn add --dev postcss
$ yarn test
...
Test Suites: 1 failed, 1 total
Tests: 2 failed, 7 passed, 9 total
... |
same problem |
Had the same issue in a yarn workspaces project. As mentioned the problem was caused by a module depending on PostCSS@7. I used
So I added the following to my root package.json: "resolutions": {
"postcss": "^8.3.11"
}, After running |
This is likely caused by an incompatible version of PostCSS in the tree. If you still need PostCSS 7 as root dependancy, I suggest to upgrade all related dependencies to use PostCSS 8 before upgrading Stylelint and related configurations and plugins. |
Yeah, my projects that use either latest Vuetify or Nuxt all are "stuck" with PostCSS@7 and that's not gonna change soon. Yes, there are alpha/beta versions of newer versions, but it might take years until they go GA and we can use PostCSS@8 there. Ended up disabling stylelint for now :( |
Same issue over here while updating to Stylelint 14. |
Still having "When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-scss", and use the "customSyntax" option" after getting everything to the latest version. |
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?
My PR can be seen here: spaceninja/stylelint-config-spaceninja#171
The failing tests are here: https://github.com/spaceninja/stylelint-config-spaceninja/runs/3970823065?check_suite_focus=true
The text was updated successfully, but these errors were encountered: