[Fixed] Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:413:11) – Spawn

by
Ali Hasan
child-process ionic-framework node.js spawn vagrant-windows

Quick Fix: Run the command in Command Prompt and then restart your PC:

REG add HKCU\Software\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 0 /f

The Problem:

You are getting an error "Error: spawn UNKNOWN at ChildProcess.spawn (node:internal/child_process:413:11)" when using Ionic with Angular. This error occurs when trying to use NPX commands that use child processes. You have tried various troubleshooting steps like changing Node versions, comparing versions with colleagues, reinstalling software, and giving admin privileges, but nothing has worked. You are using Windows 11 and VS Code, and this issue has spread to any NPX command using a child process.

The Solutions:

Solution 1: Disable Hyper-V

If you have installed any Android emulators, they may have enabled Hyper-V, which can cause issues with child processes. Try disabling Hyper-V in your computer’s settings.

Solution 2: Reset Command Prompt Settings

Run the following command in Command Prompt as an administrator:

REG add HKCU\Software\Policies\Microsoft\Windows\System /v DisableCMD /t REG_DWORD /d 0 /f

This will reset the Command Prompt settings and potentially resolve the issue.

Solution 2: Run softwareupdate –install-rosetta

If you are encountering the same problem on a Mac, executing the command softwareupdate –install-rosetta can provide a solution. This command resolved the issue for me, despite trying various node versions and adjusting folder permissions. The error arose because the Apple Silicon M2 Chip lacked support. Rosetta’s role is to convert x64 executables to ARM, eliminating the error. You can find more information about this solution on GitHub: https://github.com/pa11y/pa11y/issues/619.

Solution 3: Antivirus Software

The error “spawn UNKNOWN” can sometimes be caused by antivirus software interfering with the child process. Removing the antivirus program can fix the issue.

Q&A

What are some possible solutions to this error?

Try turning off Hyper-V or disabling Command Prompt in Windows Registry.

How to resolve this error on Mac?

Install Rosetta using the command ‘softwareupdate –install-rosetta’.

Can antivirus software cause this error?

Yes, uninstalling antivirus software may resolve the issue.