我今天有点失落。我想将 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}\"
从终端我注意到一切都运行良好,但当我在我的 Angular 项目中使用 scss 时,我看到了一些错误。为了防止这些基于 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 软件包,但我得到了同样的错误?还有其他人遇到过这个问题并且能够解决它吗?
提前谢谢了。