我今天有點失落。我想將 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 包,但我得到了同樣的錯誤?有沒有其他人遇到過這個問題并且能夠解決它?
提前謝謝了。
uj5u.com熱心網友回復:
我遇到了這個問題,我設法通過在 package.json 檔案中添加 postcss 作為開發依賴項來解決這個問題,例如:
"devDependencies": {
"postcss": "^8.4.13"
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/476929.html
