如何查找 Angular Invalid version 15.2-15.3 错误?

won*_*rld 31 angular-cli

我使用 Angular CLI 13.0.4 创建了一个新的 Angular 应用程序。它创建了一个 Angular 应用程序版本 ~13.0.0。当我使用该命令时ng build,出现以下错误:

./node_modules/css-loader/dist/runtime/api.js - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Transform failed with 1 error:
error: Invalid version: "15.2-15.3"

./node_modules/css-loader/dist/runtime/noSourceMaps.js - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Transform failed with 1 error:
error: Invalid version: "15.2-15.3"
Run Code Online (Sandbox Code Playgroud)

这些是我使用的不同版本:

在此输入图像描述

我应该怎么做才能修复这个错误?

------ 更新 2022 年 3 月 2 日 ------

browserlist文件的内容:

# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries

# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support

# You can see what browsers were selected by your queries by running:
#   npx browserslist

last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
Run Code Online (Sandbox Code Playgroud)

won*_*rld 51

last 2 Safari major versions我从文件中注释掉了该行.browserslistrc。正在npm build成功构建应用程序。

  • 更新最新版本的 build-Angular 为我解决了这个问题。 (3认同)
  • 它看起来像`@angular-devkit/build-angular`的版本,[关于问题](https://github.com/angular/angular-cli/issues/22606#issuecomment-1062016148) (2认同)

小智 30

尝试npm audit fixnpm audit fix --force由于“错误:无效版本:“15.2-15.3””此错误是由于安装了无效版本造成的,因此,由于这是在 npm@6 中引入的,审核修复将自动解决依赖性问题。

  • `npm 审核修复 --force` 有效 (4认同)

小智 18

npm audit fix --force更新后我必须运行.browserslistrc,它对我有用。

如何查找 Angular Invalid version 15.2-15.3 错误


Fre*_*e09 7

将此库更新到最新的主要版本,它应该可以解决此问题

yarn add @angular-devkit/build-angular -D
Run Code Online (Sandbox Code Playgroud)

如果您使用的是 Angular 13 例如运行此命令

yarn add @angular-devkit/build-angular@13.3.7 -D
Run Code Online (Sandbox Code Playgroud)

或使用 npm 进行相同操作

npm i --save-dev @angular-devkit/build-angular@13.3.7
Run Code Online (Sandbox Code Playgroud)


小智 5

命令“npmauditfix”对我有用