Angular 18 error after update:An unhandled exception occurred: (0 , os_1.availableParallelism) is not a function
Asked Answered
S

1

5

Could anyone advise after Angular update up to 18 I got:

An unhandled exception occurred: (0 , os_1.availableParallelism) is not a function

In angular-errors.log

[error] TypeError: (0 , os_1.availableParallelism) is not a function at Object.<anonymous> (C:\Users\Zendbook\Documents\DILAU\tracker-users-web\node_modules\piscina\dist\src\index.js:37:54) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) at Module.load (node:internal/modules/cjs/loader:1081:32) at Module._load (node:internal/modules/cjs/loader:922:12) at Module.require (node:internal/modules/cjs/loader:1105:19) at require (node:internal/modules/cjs/helpers:103:18) at Object.<anonymous> (C:\Users\Zendbook\Documents\DILAU\tracker-users-web\node_modules\piscina\dist\src\main.js:5:33) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) How to fix ?

try to find answer in google.

Soandso answered 23/5, 2024 at 10:11 Comment(2)
Which node version are you using? Also, which command did you run that caused the error?Geo
nodejs:v18.13.0, i build as npm serveSoandso
G
12

This is an issue with the piscina package, which is a dependency of @angular-devkit/build-angular. It only happens on older NodeJS versions, see the related GitHub issue. They have already provided a fix with piscina v4.5.1, however it didn't make Angular v18.0.x. Here are a few options how you can fix it:

  • Update to Angular >=18.1.0, where the dependency update is included
  • Update to Node >=18.19.1 (minimum for Angular v18), or better v20
  • Force piscina version 4.5.1 with an npm override
Geo answered 23/5, 2024 at 10:44 Comment(3)
I mean release is a big deal, right. Do not they test before they do the release. It just breaks my heart how these issues affecting all of us because of these kind of weak release mindset.Cushing
@TadeleAyelegn They perform tests with the supported versions. The issue only occurs on versions which fall out of the supported version range. Users will get warnings about this. If they ignore this warnings, why should Angular be to blame?Geo
Yes npm and all of it's inter-dependencies make life hard, mostly because of lack of testing.Knotting

© 2022 - 2025 — McMap. All rights reserved.