'Angular - An unhandled exception occurred: spawn UNKNOWN

In Angular-13 project I have a project that has been working very fine. But suddenly, when I did ng serve I got this error:

An unhandled exception occurred: spawn UNKNOWN
See "C:\Users\JOSHU~1.IBE\AppData\Local\Temp\ng-i3hvNX\angular-errors.log" for further details.

The error log gives:

[error] Error: spawn UNKNOWN
    at ChildProcess.spawn (node:internal/child_process:413:11)
    at Object.spawn (node:child_process:700:9)
    at baseOpen (C:\MyProject\LMS-UI\node_modules\open\index.js:205:34)
    at async MergeMapSubscriber.project (C:\MyProject\LMS-UI\node_modules\@angular-devkit\build-angular\src\builders\dev-server\index.js:220:21)

I did this:

  1. remove node_modules rm -rf node_modules or just delete them
  2. run npm i or npm i --only=dev(only when all modules are already installed just need to save the dev dependencies)
  3. run ng serve or npm start

But the problem still remains.

How do I resolve the problem?

Thank you



Solution 1:[1]

Like you can see in the stack trace, the error is thrown by the open npm package. They have an open GitHub issue where users of the Windows CMD have exactly the same issue like you do: https://github.com/sindresorhus/open/issues/205

Please try another shell, e.g. PowerShell.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JSON Derulo