hudochenkov / postcss-styled-syntax

PostCSS syntax for CSS-in-JS like styled-components
MIT License
69 stars 4 forks source link

Error: Cannot resolve custom syntax module "postcss-styled-syntax" #19

Closed Spielboerg closed 10 months ago

Spielboerg commented 11 months ago

When I run stylelint with postcss-styled-syntax, I get this error message:

$ stylelint .

Error: Cannot resolve custom syntax module "postcss-styled-syntax". Check that module "postcss-styled-syntax" is available and spelled correctly.

Caused by: Error: Cannot find module 'typescript'
Require stack:
- <project-path>/node_modules/@typescript-eslint/typescript-estree/dist/convert.js
- <project-path>/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js
- <project-path>/node_modules/@typescript-eslint/typescript-estree/dist/parser.js
- <project-path>/node_modules/@typescript-eslint/typescript-estree/dist/index.js
- <project-path>/node_modules/postcss-styled-syntax/lib/parse.js
- <project-path>/node_modules/postcss-styled-syntax/lib/index.js
- <project-path>/node_modules/stylelint/lib/getPostcssResult.js
- <project-path>/node_modules/stylelint/lib/lintSource.js
- <project-path>/node_modules/stylelint/lib/standalone.js
    at getCustomSyntax (<project-path>/node_modules/stylelint/lib/getPostcssResult.js:85:11)
    at getPostcssResult (<project-path>/node_modules/stylelint/lib/getPostcssResult.js:32:5)
    at lintSource (<project-path>/node_modules/stylelint/lib/lintSource.js:99:10)
    at async <project-path>/node_modules/stylelint/lib/standalone.js:211:27
    at async Promise.all (index 0)
    at async standalone (<project-path>/node_modules/stylelint/lib/standalone.js:254:22)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Process finished with exit code 1

Note: I replaced the original file paths with <project-path>.

We do not use Typescript in our projects, nor do we want to install it just for stylelint. There is also another issue (#12) related to Typescript.

You can find a minimalistic setup for reproduction here: https://stackblitz.com/edit/stylelint-custom-syntax-error?file=package.json Steps:

  1. Wait for automatic dependency installation
  2. Run stylelint .
  3. See error from above
hudochenkov commented 10 months ago

Thank you for providing a reproduction.

Issues reproduced by using legacy packet manager — Yarn 1 — which doesn't install peer dependencies, unlike npm or pnpm. While this project doesn't directly dependent on typescript package, project dependencies do have peer dependencies on typescript.

I'll take a look how to best address this.

hudochenkov commented 10 months ago

Should be fixed in 0.5.0.

Spielboerg commented 10 months ago

Yes, thank you @hudochenkov!