angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build error: Invalid version: "15.2-15.3"

Open shakeri opened this issue 4 years ago β€’ 78 comments

🐞 Bug report

Command (mark with an x)

  • [ ] new
  • [x] build
  • [ ] serve
  • [ ] test
  • [ ] e2e
  • [ ] generate
  • [ ] add
  • [ ] update
  • [ ] lint
  • [ ] extract-i18n
  • [ ] run
  • [ ] config
  • [ ] help
  • [ ] version
  • [ ] doc

Description

When i build project with Angular CLI, I get this error:

An unhandled exception occurred: Transform failed with 1 error: error: Invalid version: "15.2-15.3" See "C:\Users\MOHAMM~1\AppData\Local\Temp\ng-JBqIfM\angular-errors.log" for further details.

And in angular-errors.log file:

[error] HookWebpackError: Transform failed with 1 error:
error: Invalid version: "15.2-15.3"
    at makeWebpackError (E:\workingfolder\test-app\node_modules\webpack\lib\HookWebpackError.js:48:9)
    at E:\workingfolder\test-app\node_modules\webpack\lib\Compilation.js:3057:12
    at eval (eval at create (E:\workingfolder\test-app\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:98:1)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
-- inner error --
Error: Transform failed with 1 error:
error: Invalid version: "15.2-15.3"
    at failureErrorWithLog (E:\workingfolder\test-app\node_modules\@angular-devkit\build-angular\node_modules\esbuild\lib\main.js:1557:15)
    at E:\workingfolder\test-app\node_modules\@angular-devkit\build-angular\node_modules\esbuild\lib\main.js:1346:29
    at E:\workingfolder\test-app\node_modules\@angular-devkit\build-angular\node_modules\esbuild\lib\main.js:637:9
    at handleIncomingPacket (E:\workingfolder\test-app\node_modules\@angular-devkit\build-angular\node_modules\esbuild\lib\main.js:734:9)
    at Socket.readFromStdout (E:\workingfolder\test-app\node_modules\@angular-devkit\build-angular\node_modules\esbuild\lib\main.js:604:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:199:23)

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / β–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 13.2.0
Node: 16.13.2
Package Manager: npm 8.4.0
OS: win32 x64

Angular: 13.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.0
@angular-devkit/build-angular   13.2.0
@angular-devkit/core            13.2.0
@angular-devkit/schematics      13.2.0
@schematics/angular             13.2.0
rxjs                            7.5.2
typescript                      4.5.5

shakeri avatar Jan 29 '22 20:01 shakeri

I have updated to 13.2.1 but still got this error. (Nx repo maybe also an existing error there?)

I confirm the same - using Nx and after upgrading to 13.2.1 nothing changed. Still the same error.

KirillMetrik avatar Feb 01 '22 10:02 KirillMetrik

I had to run: ng update @angular/[email protected] ng update @angular-devkit/[email protected] --legacy-peer-deps

And this worked

JKennedy24 avatar Feb 01 '22 10:02 JKennedy24

@alan-agius4 I would like to confirm, that after I have run ng update @angular/cli compilation goes without any issue.

henrikdahl8240 avatar Feb 01 '22 10:02 henrikdahl8240

12.2.6 upgrade alone does not work for those building libraries. ng-packager also needs an update (12.2.7 worked)

Ketec avatar Feb 02 '22 11:02 Ketec

I resolved the problem. Create a file in the root directory with the name ".browserslistrc" and put into it the following content:

# 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 IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
not ios_saf 15.2-15.3
not safari 15.2-15.3

This worked for me! Thanks.

campelo avatar Feb 04 '22 13:02 campelo

added the following lines to the default .browserslistrc, and it was resolved.

not ios_saf 15.2-15.3 not safari 15.2-15.3

DevilishMan avatar Feb 08 '22 03:02 DevilishMan

I have removed everything there(.browserslistrc) and no issues for me now. I develop Native iOS and Android apps using Ionic.

Sampath-Lokuge avatar Feb 10 '22 15:02 Sampath-Lokuge

@Sampath-Lokuge Please allow me to ask you a question, which is a bit off topic. I would say that I am rather mastering Angular and I have a master's degree in computer science. I could also be interested in developing native IOS and Android apps, e.g. using Ionic. Therefore I would like to kindly ask you, is it relatively easy and quick to learn or is it a huge field it requires many, many hours for studying in order to do something meaningful, i.e. professional app, when considering the Ionic contribution in workload?

henrikdahl8240 avatar Feb 10 '22 15:02 henrikdahl8240

Hi @henrikdahl8240 If you know Angular then learning Ionic is super easy. I would like to help you here. i.e. I can recommend good courses and etc. to you. You can find out my email on my Git profile.

Sampath-Lokuge avatar Feb 10 '22 15:02 Sampath-Lokuge

Hi @Sampath-Lokuge It is really kind of you! Would you say, that Ionic has such a mature quality, that you may rely on it for professional apps or does the environments have its own difficulties? Do you know if it's possible to do proper barcode reading using the camera and proper printing using AirPrint when you make an Ionic app?

henrikdahl8240 avatar Feb 10 '22 16:02 henrikdahl8240

Hi @henrikdahl8240 Yes, I have developed around 30 Native Ionic/Angular apps within the last 6 years for the USA and European clients. So we can have almost any native feature using Capacitor and Cordova plugins. It has that much of a huge list of native plugins.

Cordova Plugins: https://ionicframework.com/docs/native

Capacitor Plugins: https://github.com/riderx/awesome-capacitor

Sampath-Lokuge avatar Feb 10 '22 16:02 Sampath-Lokuge

@henrikdahl8240 @Sampath-Lokuge Please use discussions for off-topic to not flood people listening on this issue.

viceice avatar Feb 10 '22 17:02 viceice

Updating with ng update didnt resolve it, in my case adding the 2 lines in .browserslistrc did

added the following lines to the default .browserslistrc, and it was resolved.

not ios_saf 15.2-15.3 not safari 15.2-15.3

panchazo avatar Feb 11 '22 15:02 panchazo

It works Thanks

tonovarela avatar Feb 11 '22 23:02 tonovarela

hello guys,

adding all of the above solution didnt work for me.

So I had to run npm audit fix --force after updating .browserslistrc, and it worked for me.

nimatrazmjo avatar Feb 12 '22 05:02 nimatrazmjo

Hello guys, I am really new to angular (but have used maven a lot). I would like to learn how to pack a angular app with maven and run it from a app-server like weblogic for eg. If I remeber correct used this tutorial (or any plain vanilla angular-app I guess would work as well):

https://vorozco.com/blog/2019/2019-09-11-Packagin-Angular-8-Apps-War.html

But during this work I run into the same problem as in this thread.

I did not have a .browserlistrc file. But I had a package.json-file. I just took a wild stab in the dark and changed the following in that file:

"devDependencies": { "@angular-devkit/build-angular": "~13.1.1", "@angular/cli": "~13.1.1",

to "devDependencies": { "@angular-devkit/build-angular": "~13.2.1", "@angular/cli": "~13.2.1",

Voila it builds.

Please comment if this is a bad solution. How ever it now seems to be able to pack witk maven and run from my weblogic 14.1.1 Best regards Fredrik

fredand44 avatar Feb 14 '22 18:02 fredand44

What is the impact of the built artefacts when excluding iOS Safari and Safari from the list of browsers please? Any negative impact we should be aware of?

And, i understand this to be a work-around, think the right solution is to make transitive dependencies work in the build process. Any perspectives and timelines here?

Cheers,

lukzard avatar Feb 15 '22 09:02 lukzard

you should yourself create .browserlistsrc file incase it is not present in your project folder.

harisiltifat avatar Feb 22 '22 17:02 harisiltifat

So editing .browserslistrc is a nonsense. Just update your ng upto 13.2. Check your global and local versions of Angular CLI.

oshliaer avatar Feb 23 '22 05:02 oshliaer

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

Firefox ESR not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

I had to remove

package.json

{
...
  "browserslist": [
    "and_chr 97",
    "and_ff 95",
    "and_qq 10.4",
    "and_uc 12.12",
    "android 97",
    "baidu 7.12",
    "chrome 97",
    "chrome 96",
    "chrome 95",
    "chrome 94",
    "edge 97",
    "edge 96",
    "firefox 96",
    "firefox 95",
    "firefox 94",
    "firefox 91",
    "firefox 78",
    "ie 11",
    "ios_saf 15.0-15.1",
    "ios_saf 14.0-14.4",
    "kaios 2.5",
    "op_mini all",
    "op_mob 64",
    "opera 82",
    "safari 13.1",
    "samsung 16.0",
    "samsung 15.0"
  ],
  ...
}

This worked for me.

I had to remove Android 97 to make this work.

By adding these browserlist my main.js bundle size slightly increased. It was 3.71 mb and now its 4.02mb

Santoshah avatar Feb 24 '22 03:02 Santoshah