gpt4 book ai didi

angular - stylelint 在引入 stylelint-config-standard-scss 时给出错误 "Class extends value undefined is not a constructor or null"

转载 作者:行者123 更新时间:2023-12-05 02:29:16 45 4
gpt4 key购买 nike

我今天有点不知所措。我想将 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}\" 我注意到一切正常,但因为我在中使用 scss在我的 Angular 项目中,我看到了一些错误。为了防止这些基于 scss 的错误,我决定引入 stylelint-config-standard-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/**/*.{css,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 包,但我得到了同样的错误?有没有其他人遇到过这个问题并且能够解决它?

非常感谢。

最佳答案

我有这个问题,我设法通过在 package.json 文件中添加 postcss 作为开发依赖来解决这个问题,例如:

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

关于angular - stylelint 在引入 stylelint-config-standard-scss 时给出错误 "Class extends value undefined is not a constructor or null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72272219/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com