How to find the angular Invalid version 15.2-15.3 error?

Viewed 18629

I created a new angular app with the angular CLI 13.0.4. It created an angular app version ~13.0.0. When I use the command ng build, I get the following error:

./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"

These are the different version that I use:

enter image description here

What should I do to fix this error?

------ UPDATE 3/2/2022 ------

Contents of the browserlist file:

# 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
8 Answers

I commented out the line last 2 Safari major versions from the .browserslistrc file. The npm build is building the application successfully.

Try npm audit fix or npm audit fix --force since "error: Invalid version: "15.2-15.3"" this error is due to an invalid version installed, therefore as this was introduced in npm@6 audit fixing will automatically resolve dependence issues.

The command "npm audit fix" works for me

enter image description here

I removed the last two Safari major versions from the .browserslistrc file after which the build is created successfully.

After removing the last two Safari major versions:

enter image description here

Update this library to the latests major version and it should fix this issue

yarn add @angular-devkit/build-angular -D

if you are using angular 13 e.g. run this command

yarn add @angular-devkit/build-angular@13.3.7 -D

or the same using npm

npm i --save-dev @angular-devkit/build-angular@13.3.7

I got this problem after updating my browserslist, and npm update fixed it for me.

As explained here by an Angular collaborator:

This is just a bug in the parsing logic of Safari browser versions

You can simply add

not ios_saf 15.2-15.3
not safari 15.2-15.3

in your .browserslistrc file of your project

Related