英文:
Angular 8 build environmental issue. "Compound selectors may no longer be extended"
问题
抱歉,你提供的文本包含了一些代码和错误信息,我将只翻译非代码部分和一些关键信息:
"We have an older Angular 8 app that has some bit rot. We brought in a new developer and we are planning on upgrading everything to ng latest. I have an M1 Mac and everything builds fine on my machine. He has an Intel-based Mac, but when he tries to build, he gets the error below. Node, Npm, Angular CLI versions have all been downgraded to match mine, but still no luck.
ERROR in ./src/assets/scss/theme.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@extend .k-button::before;
^
Compound selectors may no longer be extended.
Consider @extend .k-button, ::before instead.
See ExtendCompound for details.
105 │ @extend .k-button::before;
│ ^^^^^^^^^^^^^^^^^
node_modules/@progress/kendo-theme-bootstrap/modules/@progress/kendo-theme-default/scss/toolbar/_layout.scss 105:25 root stylesheet
in /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/@progress/kendo-theme-bootstrap/modules/@progress/kendo-theme-default/scss/toolbar/_layout.scss (line 105, column 25)
ERROR in node_modules/@types/node/assert.d.ts(2,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(53,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(62,94): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(62,101): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(62,104): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(64,98): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(64,105): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(64,108): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(72,47): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(72,53): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(72,56): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(99,61): error TS1005: ';' expected.
node_modules/pdfjs-dist/types/src/display/annotation_storage.d.ts(66,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/annotation_storage.d.ts(80,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/api.d.ts(1410,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/api.d.ts(1466,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/annotation_editor_layer.d.ts(190,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/editor.d.ts(225,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(173,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(245,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(271,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/metadata.d.ts(10,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/optional_content_config.d.ts(11,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/annotation_editor_layer_builder.d.ts(55,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/pdf_find_controller.d.ts(83,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/text_accessibility.d.ts(41,5): error TS1127: Invalid character."
希望这对你有所帮助。
英文:
We have an older Angular 8 app that has a some bit rot. We brought in a new developer and we are planning on upgrading everything to ng latest. I have an M1 Mac and everything builds fine on my machine. He has an intel based Mac, but when he tries to build, he gets the error below. Node, Npm, Angular CLI versions have all be downgraded to match mine, but still no luck.
ERROR in ./src/assets/scss/theme.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
@extend .k-button::before;
^
Compound selectors may no longer be extended.
Consider `@extend .k-button, ::before` instead.
See ExtendCompound for details.
╷
105 │ @extend .k-button::before;
│ ^^^^^^^^^^^^^^^^^
╵
node_modules/@progress/kendo-theme-bootstrap/modules/@progress/kendo-theme-default/scss/toolbar/_layout.scss 105:25 root stylesheet
in /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/@progress/kendo-theme-bootstrap/modules/@progress/kendo-theme-default/scss/toolbar/_layout.scss (line 105, column 25)
at /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/webpack/lib/NormalModule.js:316:20
at /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/loader-runner/lib/LoaderRunner.js:233:18
at context.callback (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass-loader/lib/loader.js:52:13
at Function.$2 (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:24388:48)
at wO.$2 (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:15315:15)
at uT.vr (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:9046:42)
at uT.vq (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:9048:32)
at iA.uD (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8396:46)
at us.$0 (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8538:7)
at Object.eH (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:1512:80)
at ad.ba (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8459:3)
at iO.ba (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8389:25)
at iO.cv (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8376:6)
at py.cv (/Users/redacted/Development/Personal/repos/Projects/Proverbs/redacted/src/redacted.Web/ClientApp/node_modules/sass/sass.dart.js:8166:35)
ERROR in node_modules/@types/node/assert.d.ts(2,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(53,68): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(62,94): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(62,101): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(62,104): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(64,98): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(64,105): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(64,108): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(72,47): error TS1144: '{' or ';' expected.
node_modules/@types/node/assert.d.ts(72,53): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(72,56): error TS1005: ';' expected.
node_modules/@types/node/assert.d.ts(99,61): error TS1005: ';' expected.
node_modules/pdfjs-dist/types/src/display/annotation_storage.d.ts(66,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/annotation_storage.d.ts(80,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/api.d.ts(1410,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/api.d.ts(1466,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/annotation_editor_layer.d.ts(190,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/editor.d.ts(225,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(173,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(245,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/editor/tools.d.ts(271,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/metadata.d.ts(10,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/src/display/optional_content_config.d.ts(11,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/annotation_editor_layer_builder.d.ts(55,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/pdf_find_controller.d.ts(83,5): error TS1127: Invalid character.
node_modules/pdfjs-dist/types/web/text_accessibility.d.ts(41,5): error TS1127: Invalid character.
答案1
得分: 1
你应该检查你的 angular.json 文件,看是否需要将 style
和 skipTests
重命名为版本 8 中已废弃的 styleext
和 spec
。
请查看以下链接:
https://github.com/angular/angular-cli/commit/e92c46a
英文:
You should check if you have to rename style
and skipTests
to versions 8 deprecated styleext
and spec
inside your angular.json file.
Check the following link:
https://github.com/angular/angular-cli/commit/e92c46a
答案2
得分: 1
我认为你的问题与Angular/Node/NPM无关,而与SASS有关。你是否检查过你和同事使用的是相同版本(dart或libsass)?我不得不稍微查找一下才找到它(之前也遇到过相同的问题),但这是参考链接:https://sass-lang.com/documentation/breaking-changes/extend-compound
英文:
I don't think your problem is with Angular/Node/NPM but rather with SASS, did you check that you have the same version (either dart or libsass?) as your colleague? Had to dig a little to find it again (had the same issue a while ago) but here it is for reference: https://sass-lang.com/documentation/breaking-changes/extend-compound
答案3
得分: 1
似乎是与Sass-loader库有关的问题,该库用于将Sass代码转换为CSS代码。根据错误消息,不再支持扩展复合选择器。您尝试按照错误消息建议的方式操作了吗?
考虑在theme.scss中使用
@extend .k-button, ::before
,而不是@extend .k-button::before
您还应该检查是否使用了相同版本的Sass-loader。
您还可以尝试删除node_modules,使用npm cache clean清除缓存,然后重新安装依赖项。
英文:
It seems to be a problem with the Sass-loader library, which is used to convert Sass code to CSS code. According to the error message, compound selectors can no longer be extended. Have you tried doing what error message suggests?
> Consider using @extend .k-button, ::before
instead of @extend
in theme.scss
> .k-button::before
You should also check that you are using the same version of Sass-loader.
You can also try removing the node_modules, clearing the cache with npm cache clean and re-installing the dependencies.
答案4
得分: 1
如果您看到错误本身,它会解释错误,这是我引用的错误
@extend .k-button::before;
复合选择器不再可扩展。
考虑改用 @extend .k-button, ::before
。
问题是由于Sass @extend的重大更改引起的。查看文档示例
重大更改:扩展复合选择器
LibSass目前允许扩展复合选择器,例如 .message.info,但它的扩展方式不符合@extend的预期工作方式。
// 不再使用 .message.info
。
%message-info, .message.info {
border: 1px solid black;
font-size: 1.5rem;
}
.heads-up {
// 不再使用 .message.info
。
@extend %message-info;
}
请查看原始文档以获取示例。
英文:
If you see the error itself, it explains the error, which is from your errors I am quoting
@extend .k-button::before;
Compound selectors may no longer be extended.
Consider `@extend .k-button, ::before` instead.
The issue is because of the breaking change with sass @extend. Check Docs Example
> Breaking Change: Extending Compound Selectors
>
> LibSass currently allows compound selectors like .message.info to be
> extended, but the way it was extended doesn't match the way @extend is
> meant to work.
// Instead of just `.message.info`.
%message-info, .message.info {
border: 1px solid black;
font-size: 1.5rem;
}
.heads-up {
// Instead of `.message.info`.
@extend %message-info;
}
Kindly check the original docs for example
答案5
得分: 0
- 可能性1:错误的
package-lock
版本控制
可能是你的package-lock.json
文件没有纳入版本控制。在运行npm install
之前,请确保你的机器和另一台机器的package-lock
文件是完全相同的。
如果这被确认为问题,这意味着你的 TypeScript 版本与一些 @types
包之间存在不兼容问题。它在你的机器上工作是因为你的 package-lock
文件将其“锁定”到兼容版本上。另外,npm update
也会因为相同的原因导致问题。
- 可能性2:类型问题
可能是CRLF
(Windows)、LF
(Unix 和 Mac)与CR
(旧版 Mac)之间的差异问题2。
如果代码是在 Mac 上编写的,那么它可能只使用 LF
。git
有一个 autocrlf
选项,你需要正确配置它以透明处理这些问题。尝试重新下载项目并运行 --renormalize
:
git add --renormalize
来自文档:
> 对所有已跟踪的文件重新应用“clean”处理,以强制将它们重新添加到索引中。这在更改了 core.autocrlf 配置或文本属性以纠正添加了错误的 CRLF/LF 行结束的文件时非常有用。此选项隐含 -u。
英文:
I can think of the following possibilities:
1. Wrong package-lock control version
It could be that your package-lock.json
file is not on your version control.
Before of npm install
: make sure that both, yours and the other machine are exactly the same.
If this turns out to be the problem, it means that there's an incompatibility issue between your TypeScript version and some of your @types
packages. It works in your machine because your package-lock
file "locked it" to a compatible one there. Also, npm update
will break things for the same reasons.
2. Break types issue
It might be a CRLF
(Windows), LF
(Unix and Mac) vs CR
(Old Mac) differences issue.
If the code was written using a MAC, then it's probably using LF
only. git
has an autocrlf
option which you have to configure correctly to handle things transparently. Try to download the project again and run --renormalize
:
git add --renormalize
From documentation:
> Apply the "clean" process freshly to all tracked files to forcibly add
> them again to the index. This is useful after changing core.autocrlf
> configuration or the text attribute in order to correct files added
> with wrong CRLF/LF line endings. This option implies -u.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论