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

ResolvΓ­ el problema. Cree un archivo en el directorio raΓ­z con el nombre ".browserslistrc" y coloque en Γ©l el siguiente contenido:

# 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

Eres Dios bro, muchas gracias.

bedoya199712 avatar Feb 25 '22 04:02 bedoya199712

Hello Guys i try npm audit fix --force after updated, browserlist file with below. last 2 Chrome version last 2 Firefox version last 2 Edge major versions last 2 Safari major versions last 2 iOS major versions Firefox ESR not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. it's resolved with me

hamza124 avatar Mar 01 '22 07:03 hamza124

I had to remove Android 97 to make this work.

I also had the "Unknown version 97 of android" exception, but instead of removing that entry altogether, after some code editing (in node_modules\browserslist\index.js) and testing I found out that changing android's version to 98 in .browserslistrc caused the build to succeed. It doesn't seem to be a common error, as that specific exception message doesn't appear in Google Search.

Badawi7 avatar Mar 02 '22 06:03 Badawi7

I can fix the error without changing the .browserslistrc by updating the angular compiler version to 13.2.5 or later:

"@angular-devkit/build-angular": "~13.2.5",

beenotung avatar Mar 08 '22 17:03 beenotung

Yes, once released 13.2.1should contain the fix for this issue.

That's great. Thanks. Any chance the fix is going to be pushed into Angular 12? Using the latest Angular 12 (12.2.16) compiler also has this issue.

eemt avatar Mar 09 '22 21:03 eemt

I can fix the error without changing the .browserslistrc by updating the angular compiler version to 13.2.5 or later:

"@angular-devkit/build-angular": "~13.2.5",

This solution worked for me. :+1:

webcat12345 avatar Mar 10 '22 15:03 webcat12345

@eemt, this should be fixed in 12.2.16. Can you confirm that all your Angular packages are updated? If you still see the error, can you post ng version?

dgp1130 avatar Mar 10 '22 18:03 dgp1130

@dgp1130 I had updated @angular/compiler, @angular/cli & @angular/compiler-cli to 12.2.16, but I hadn't updated core and common (12.2.15). Now that I updated core and common to 12.2.16, the error is indeed gone.

Thanks!

eemt avatar Mar 10 '22 23:03 eemt

I'm using Angular 13.2.6 and still have the problem in our CI build (not locally, though).

alessiostalla avatar Mar 16 '22 08:03 alessiostalla

I still get this error 13.1.4 with range in browserlist

Angular CLI: 13.1.4 Node: 16.13.0 Package Manager: npm 8.1.4 OS: win32 x64

Angular: 13.1.3 ... animations, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, router ... service-worker

Package Version

@angular-devkit/architect 0.1301.4 @angular-devkit/build-angular 13.1.4 @angular-devkit/core 13.1.4 @angular-devkit/schematics 13.1.4 @angular/cdk 13.2.6 @angular/cli 13.1.4 @schematics/angular 13.1.4 rxjs 7.4.0 typescript 4.5.5

i cant go above as i have peer dependency, nice update there i will have to roll back angular to lower version as was ok there,

chalkplum avatar Mar 16 '22 11:03 chalkplum

I have solved that by doing:

ng update @angular/core @angular/cli
ng update

Hope it helps.

TomCosta avatar Mar 30 '22 15:03 TomCosta

I have solved that by doing:

ng update @angular/core @angular/cli
ng update

Hope it helps.

Didn't work for me

alessiostalla avatar Mar 30 '22 17:03 alessiostalla

I had to remove every line resolving to a safari browser from my browserslist to make the build work again. This also means removing lines lie >1% in de.

hoeni avatar Apr 04 '22 15:04 hoeni

My approach for a starter project I used (unfamiliar to me):

grep -R 'last 2 Safari major' .

./node_modules/@angular-devkit/build-angular/src/utils/supported-browsers.js:        'last 2 Safari major versions',
./node_modules/@schematics/angular/library/files/.browserslistrc.template:last 2 Safari major versions
./node_modules/@schematics/angular/application/files/.browserslistrc.template:last 2 Safari major versions

npm ls @angular-devkit/build-angular

[...]
└── @angular-devkit/[email protected]

npm ls @schematics/angular

[...]
└─┬ @angular/[email protected]
  └── @schematics/[email protected]

(Using david, a npm package update checker (install it using npm install -g david / yarn global add david)).

david | grep @angular-devkit/build-angular

β”‚ @angular-devkit/build-angular β”‚ ~13.1.0  β”‚ 13.3.2  β”‚

npm install --legacy-peer-deps --save @angular-devkit/[email protected]

david | grep @angular/cli

β”‚ @angular/cli                  β”‚ ~13.1.0  β”‚ 13.3.2  β”‚

npm install --legacy-peer-deps --save-dev @angular/[email protected]

Luckily these updates were enough to also update the browser support configurations in the affected dependencies.

strarsis avatar Apr 06 '22 21:04 strarsis

run npm audit fix --force or update @angular-devkit/build-angular

chamikasandamal avatar Apr 21 '22 10:04 chamikasandamal

run npm audit fix --force or update @angular-devkit/build-angular

I tried run this command, but I had unsuccessful.

leonardo-nicolas avatar Apr 23 '22 01:04 leonardo-nicolas

ng update @angular/core @angular/cli

First updated to Angular using npm install -g @angular/cli outside the project folder.

Angular CLI: 13.3.4
Node: 14.17.5
Package Manager: npm 8.3.0
OS: linux x64

Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1303.4 (cli-only)
@angular-devkit/core         13.3.4 (cli-only)
@angular-devkit/schematics   13.3.4 (cli-only)
@schematics/angular          13.3.4 (cli-only)

Then in my project: Had to remove the node_modules and package-lock.json after updating the version numbers. After that ran npm install again and all is working now.

In my package.json:

  "dependencies": {
    "@angular/animations": "~13.3.5",
    "@angular/cdk": "^13.3.4",
    "@angular/common": "~13.3.5",
    "@angular/compiler": "~13.3.5",
    "@angular/core": "~13.3.5",
    "@angular/forms": "~13.3.5",
    "@angular/material": "^13.3.4",
    "@angular/material-moment-adapter": "^13.3.4",
    "@angular/platform-browser": "~13.3.5",
    "@angular/platform-browser-dynamic": "~13.3.5",
    "@angular/router": "~13.3.5",

I do not have a .browserslistrc in my project folder

martinmolema avatar May 04 '22 15:05 martinmolema

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.