stylelint给出错误“类扩展值不确定的是构造函数或null”。引入Stylelint-Config-Scand-SCSS时

发布于 2025-01-29 13:01:07 字数 2129 浏览 3 评论 0原文

我今天有点损失。我想将StyleLint添加到我的Angular项目中,因此我运行

npm install stylelint stylelint-config-standard -save-dev

以安装STYLELINT和标准配置插件。然后,我创建了一个> .StylElIntrc文件并添加以下代码:

{
  "extends": ["stylelint-config-standard"],
  "rules": {
    "rule-empty-line-before": "always",
    "comment-empty-line-before": "always"
  }
}

运行以下命令npx stylelint \“ src/app/**/*。{css,scss} \/code>我注意到一切都很好,但是当我在Angular项目中使用SCS时,我看到了一些错误。为了防止这些基于SCS的错误,我决定介绍Stylelint-Config-Sconard-SCSS插件。我使用npm安装了此程序,然后在我的.stylelintrc文件中更新了代码到以下:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-standard-scss"
  ],
  "rules": {
    "rule-empty-line-before": "always",
    "comment-empty-line-before": "always"
  }
}

现在,当我运行命令npx stylelint \“ src/app/**/*。 scss} \“我会收到以下错误!

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/Users/myuser/my-project/node_modules/postcss-scss/lib/nested-declaration.js:3:33)
    at Module._compile (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/myuser/my-project/node_modules/postcss-scss/lib/scss-parser.js:4:25)
    at Module._compile (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

我不明白为什么会发生这种情况。 stylelint-config-standard-scss插件已下载,并在我的node_modules文件夹中。我的.stylelintrc文件中没有语法错误。我的节点版本不错(v14.18.1),我什至卸载并重新安装了所有NPM软件包,但我会遇到相同的错误?还有其他人有这个问题并能够解决吗?

非常感谢。

I'm at at a bit of a loss today. I wanted to add Stylelint to my Angular project, so I ran

npm install stylelint stylelint-config-standard --save-dev

to install stylelint and the standard config plug in. I then created a .stylelintrc file and added the follow code to it:

{
  "extends": ["stylelint-config-standard"],
  "rules": {
    "rule-empty-line-before": "always",
    "comment-empty-line-before": "always"
  }
}

When running the following command npx stylelint \"src/app/**/*.{css,scss}\" from the terminal I noticed all worked well but as I am using scss in my Angular project I saw some errors. To prevent these scss based errors I decided to introduce the stylelint-config-standard-scss plugin. I installed this using npm then updated the code in my .stylelintrc file to the following:

{
  "extends": [
    "stylelint-config-standard",
    "stylelint-config-standard-scss"
  ],
  "rules": {
    "rule-empty-line-before": "always",
    "comment-empty-line-before": "always"
  }
}

Now when I run the command npx stylelint \"src/app/**/*.{css,scss}\" I get the following error!

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/Users/myuser/my-project/node_modules/postcss-scss/lib/nested-declaration.js:3:33)
    at Module._compile (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/myuser/my-project/node_modules/postcss-scss/lib/scss-parser.js:4:25)
    at Module._compile (/Users/myuser/my-project/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

I can't understand why this is happening. The stylelint-config-standard-scss plugin is downloaded and in my node_modules folder. There isn't a syntax error in my .stylelintrc file. My node version is good (v14.18.1), I even uninstalled and reinstalled all npm packages but I get the same error? Has anyone else had this problem and was able to resolve it?

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烂柯人 2025-02-05 13:01:07

我遇到了这个问题,我设法通过将PostCSS添加为package.json文件中的DEV依赖项来解决此问题。

"devDependencies": {
   "postcss": "^8.4.13"
}

I had this problem, I managed to fix this by adding postcss as a dev dependency in the package.json file, for example:

"devDependencies": {
   "postcss": "^8.4.13"
}
萌辣 2025-02-05 13:01:07

我发现

I find a solution from github issue thread after google. You only need to do is to install postcss@8 with npm install.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文