Angular 12 Error … from Css Minimizer Error: Transform failed with 1 error: error: Invalid version: "15.2-15.3"

huangapple go评论50阅读模式
英文:

Angular 12 Error ... from Css Minimizer Error: Transform failed with 1 error: error: Invalid version: "15.2-15.3"

问题

我知道这个问题以前已经被问过,但我似乎遇到了一个稍微不同的问题(至少,类似问题中提供的解决方案对我来说不起作用)。

该项目正在使用 Angular 12,不幸的是,有一个必需的依赖项尚未能更新到 Angular 13。

在将库 ngx-markdown 更新到 v12.1.0 后,我遇到了错误 node_modules/marked/lib/marked.js 不存在,所以我按照 github 上建议的方法在 angular.json 脚本中更改了路径。

然后,我遇到了这个错误:

Error: Transform failed with 1 error: 
error: Invalid version: "15.2-15.3"

按照 这里 的建议,我将 @angular/cli 更新到了 12.2.16,但这对我来说并没有解决问题。

接下来,我尝试删除了 node_modules 文件以及 package-lock.json,然后重新安装了所有东西,但这也没有起作用。

然后,我尝试删除了 .browserslistrc 文件,并在其中添加了 ios_saf 15.2-15.3,这两个方法都是根据 这个 github 帖子 建议的,但都没有起作用。

有没有人有任何想法,我可以尝试下一步做什么?否则,我想最好的解决方案可能是回退到 ngx-markdown v12.0.0,尽管存在安全漏洞。

英文:

I know this question has been asked before, but I seem to have a slightly different problem (at least, the solution provided in similar questions don't work for me).

The project is using Angular 12, there is (sadly) a required dependency that has not yet been able to update to Angular 13.

After updating the library ngx-markdown to v12.1.0, I had the error that node_modules/marked/lib/marked.js does not exist, so I changed the path in the angular.json script, as suggested on github.

Then, I got this error:

Error: Transform failed with 1 error: 
error: Invalid version: "15.2-15.3"

As suggested here, I updated @angular/cli to 12.2.16, but this did not solve the issue for me.

Next, I tried to delete the node_modules file, and the package-lock.json and reinstalled everything, this also did not work.

Then, I tried to delete the .browserslistrc file, and also adding to it ios_saf 15.2-15.3, both as suggested on this github thread, but neither worked.

Does anyone have an idea what I could try next? Otherwise I guess the best solution would be to revert to ngx-markdown v12.0.0 despite the vulnerability..

答案1

得分: 0

  1. 在 angular.json 文件中更新脚本:"node_modules/marked/marked.min.js",
  2. 更新 angular/angular-devkit 版本如下:
"dependencies": {
    "@angular/animations": "12.2.0",
    "@angular/cdk": "12.2.0",
    "@angular/common": "12.2.0",
    "@angular/compiler": "12.2.0",
    "@angular/core": "12.2.0",
    "@angular/forms": "12.2.0",
    "@angular/platform-browser": "12.2.0",
    "@angular/platform-browser-dynamic": "12.2.0",
    "@angular/router": "12.2.0",
    // …
},
"devDependencies": {
    "@angular-devkit/build-angular": "12.2.16",
    "@angular-eslint/eslint-plugin": "12.3.1",
    "@angular-eslint/eslint-plugin-template": "12.3.1",
    "@angular-eslint/template-parser": "12.3.1",
    "@angular/cli": "12.2.16",
    "@angular/compiler-cli": "12.2.16",
    "@angular/language-service": "12.2.16",
    // …
}
  1. ng-packagr 更新到版本 "12.2.7".

现在它可以成功编译了,我也不需要对 browserlistrc 文件做任何更改,这通常是解决此错误的常见建议。

-> 以防有人想知道,我的 browserlistrc 文件如下:

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # 对于 IE 9-11 支持,移除 'not' 即可。

对于此评论,向 GitHub 用户 fischeversenker 致敬:https://github.com/nrwl/nx/issues/8768#issuecomment-1050710663

英文:

I managed to solve the error following these steps:

  1. Update script in angular.json "node_modules/marked/marked.min.js",
  2. Update angular/angular-devkit versions like this:
"dependencies": {
    "@angular/animations": "12.2.0",
    "@angular/cdk": "12.2.0",
    "@angular/common": "12.2.0",
    "@angular/compiler": "12.2.0",
    "@angular/core": "12.2.0",
    "@angular/forms": "12.2.0",
    "@angular/platform-browser": "12.2.0",
    "@angular/platform-browser-dynamic": "12.2.0",
    "@angular/router": "12.2.0",
// …
},
"devDependencies": {
    "@angular-devkit/build-angular": "12.2.16",
    "@angular-eslint/eslint-plugin": "12.3.1",
    "@angular-eslint/eslint-plugin-template": "12.3.1",
    "@angular-eslint/template-parser": "12.3.1",
    "@angular/cli": "12.2.16",
    "@angular/compiler-cli": "12.2.16",
    "@angular/language-service": "12.2.16",
// …
}
  1. Update ng-packagr to "12.2.7"

Now it compiles without any issues. I also didn't need any changes to the browserlistrc file, which is the commonly suggested solution for the error.

-> In case someone is wondering, my browserlistrc file looks like this:

> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.

Kudos to github user fischeversenker for this comment: https://github.com/nrwl/nx/issues/8768#issuecomment-1050710663

huangapple
  • 本文由 发表于 2023年4月6日 20:27:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949507.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定