nx: Angular production build error in nx version 13.7.1
Current Behavior
Running npx nx build results in an error
Expected Behavior
Building the application
Steps to Reproduce
- Create nx workspace with v13.7.1
- Run
npx nx build
Failure Logs
PS D:\VS Code Projects\test> npx nx build --verbose
> nx run client:build:production --verbose
⠙ Generating browser application bundles (phase: setup)...<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 15.5634 ms
⠋ Generating browser application bundles (phase: sealing)... [IdleFileCachePlugin] Initial cache was generated and cache will be persisted in 5s.
✔ Browser application bundle generation complete.
Transform failed with 1 error:
error: Invalid version: "15.2-15.3"
HookWebpackError: Transform failed with 1 error:
error: Invalid version: "15.2-15.3"
at makeWebpackError (D:\VS Code Projects\test\node_modules\webpack\lib\HookWebpackError.js:48:9)
at D:\VS Code Projects\test\node_modules\webpack\lib\Compilation.js:3057:12
at eval (eval at create (D:\VS Code Projects\test\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 (D:\VS Code Projects\test\node_modules\esbuild\lib\main.js:1557:15)
at D:\VS Code Projects\test\node_modules\esbuild\lib\main.js:1346:29
at D:\VS Code Projects\test\node_modules\esbuild\lib\main.js:637:9
at handleIncomingPacket (D:\VS Code Projects\test\node_modules\esbuild\lib\main.js:734:9)
at Socket.readFromStdout (D:\VS Code Projects\test\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)
——————————————————————————————————————————————————————————
> NX Running target "client:build" failed
Failed tasks:
- client:build:production
Hint: run the command with --verbose for more details.
PS D:\VS Code Projects\test>
Environment
PS D:\VS Code Projects\test> npx nx report
> NX Report complete - copy this into the issue template
Node : 16.13.2
OS : win32 x64
npm : 8.1.2
nx : 13.7.1
@nrwl/angular : 13.7.1
@nrwl/cli : 13.7.1
@nrwl/cypress : 13.7.1
@nrwl/detox : undefined
@nrwl/devkit : 13.7.1
@nrwl/eslint-plugin-nx : 13.7.1
@nrwl/express : undefined
@nrwl/jest : 13.7.1
@nrwl/js : undefined
@nrwl/linter : 13.7.1
@nrwl/nest : 13.7.1
@nrwl/next : undefined
@nrwl/node : 13.7.1
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.7.1
@nrwl/tao : 13.7.1
@nrwl/web : undefined
@nrwl/workspace : 13.7.1
typescript : 4.5.5
rxjs : 7.4.0
---------------------------------------
Community plugins:
@angular/animations: 13.2.0
@angular/common: 13.2.0
@angular/compiler: 13.2.0
@angular/core: 13.2.0
@angular/forms: 13.2.0
@angular/platform-browser: 13.2.0
@angular/platform-browser-dynamic: 13.2.0
@angular/router: 13.2.0
@angular-devkit/build-angular: 13.2.0
@angular/cli: 13.2.0
@angular/compiler-cli: 13.2.0
@angular/language-service: 13.2.0
(node:9932) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at D:\VS Code Projects\test\node_modules\tslib\package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 48 (10 by maintainers)
Commits related to this issue
- fixed build error: https://github.com/nrwl/nx/issues/8768 — committed to alexthelion/keycloak-login-theme-angular by alexthelion 2 years ago
- Fix angular build (see https://github.com/nrwl/nx/issues/8768) + Maj doc — committed to TwicPics/components by mbgspcii 2 years ago
- Bugfix for nx build https://github.com/nrwl/nx/issues/8768 — committed to yychan76/cnygreet by yychan76 2 years ago
- https://github.com/nrwl/nx/issues/8768 — committed to ElectroluxV2/angular-static-blog by ElectroluxV2 2 years ago
- Fix(https://github.com/nrwl/nx/issues/8768) — committed to ElectroluxV2/angular-static-blog by ElectroluxV2 2 years ago
- Fix angular build (see https://github.com/nrwl/nx/issues/8768) + Maj doc — committed to TwicPics/components by mbgspcii 2 years ago
- angular build failed - change to browserlistrc, see issue: https://github.com/nrwl/nx/issues/8768 — committed to Pier2208/wscraper by Pier2208 2 years ago
I fix the issue writing the following lines.
not ios_saf 15.2-15.3 not safari 15.2-15.3
I resolved the problem. Create a file in the root directory of the project by name “.browserslistrc” and put into it the following content:
I’m having the same error. (An unhandled exception occurred: Transform failed with 1 error: error: Invalid version: “15.2-15.3”)
FIX: At root of the app, have a .browserslistrc file, I configured this way:
Found the solution here, configured it my self https://github.com/angular/angular-cli/issues/22606
Just updated to v13.7.1 and seeing the same error
Hi , I had the same issue , without altering any files ,“npm audit fix --force”, resolved this issue . Hope it helps.
Yeah, this workaround worked for me either 👍
I temporarily fixed only changing the .browserslist file of my apps like this:
and it worked, I’ll remove the last two lines following the NX updates
Ran into the same issue. After running npx browserslist, I noticed safari 15.2-15.3 was included as well. Adding not safari 15.2-15.3 to my .browserslistrc file led to a passing build. Not sure this is a suitable solution, but is a workaround.
Worked for me
@leosvelperez Do you plan to include the fix from #8783 in a version 12 release?EDIT: After upgrading all
@angular/*and@angular-devkit/*packages to12.2.16(except@angular/cdk, which is only available as12.2.13), and updating all@nrwl/*packages to12.10.1, and - most importantly -ng-packagrto12.2.7everything works fine now 🙌Upgrading Cli and Angular worked for me.
ng update @angular/cli @angular/corethis solution does not work when creating brand new nx workspace
Updating to the latest in the @angular/* - 13.x branch helped me. Thanks @fischeversenker
this worked for me thanks
This also worked for me today.
That sounds like a cache issue on CI. As mentioned above, the apps build issue is resolved by having
@angular/clion 13.2.1 or higher, which you already have.@jogelin could you provide more details? The Nx report shows you have the right versions for the affected packages, I just created a 13.8.0 workspace and it works fine. Is it an app or a lib that’s failing?
@t-ricci-delta we didn’t include a migration (probably should), as mentioned here https://github.com/nrwl/nx/issues/8768#issuecomment-1026697752 you need to update the
@angular/cliversion to at least13.2.1to solve the app build issue.That Worked
The fixes have been released as part of
13.7.2🎉