Shane Bartholomeusz

Geek and lover of all things tech related

Solved: Angular – Invalid version: “15.2-15.3”

Problem

Whilst working on a new Angular project I recently came across an unusual error when trying to build a new project generated through the Angular CLI.

In this post, I’ll explain how I resolved this issue.

> ng build

√ Browser application bundle generation complete.
An unhandled exception occurred: Transform failed with 1 error:
error: Invalid version: “15.2-15.3”
See “XXXXXX\angular-errors.log” for further details.

Angular logo

Solution

The root cause of this problem is an incorrect configuration within the .browserslistrc browsers list file found in the root Angular project directory. This file specifies which web browsers your web application will be supporting to the various tools in the build toolchain.

The fix involves appending the following lines to the tail end of this file.

not ios_saf 15.2-15.3
not safari 15.2-15.3

As an example, my Angular project contained the following .browserslistrc file, so I appended the below red highlighted lines to resolve the issue.

# 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
not ios_saf 15.2-15.3
not safari 15.2-15.3

Final Thoughts

Well I hope this solution has resolved the Invalid version: “15.2-15.3” error for you.

If you find an alternative solution that worked for you. Feel free to post it in the comments below to help others out there.

Happy coding! 🙂

Shane Bartholomeusz

Leave a Reply

© 2024 Shane Bartholomeusz

Theme by Anders NorenUp ↑