node.jsangularangular-cliangular18

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


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.


Solution

  • 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: