NodeJs Error: spawn C:\Windows\system32\cmd.exe; ENOENT NodeJs Error: spawn C:\Windows\system32\cmd.exe; ENOENT windows windows

NodeJs Error: spawn C:\Windows\system32\cmd.exe; ENOENT


This can also be caused if you are feeding in ExecOptions the options parameter, specifically 'cwd', and the path you provide is invalid

e.g:

cp.exec(<path_to_executable>, {  cwd: <path_to_desired_working_dir>}, (err, stdout, stderr) => {  //......})

If is not valid, the callback will be called with err equal to

Error: spawn C:\Windows\system32\cmd.exe ENOENT


I got to resolve the issue the problem is to remove the semicolon(;) from an end of the ComSpec path C:\Windows\System32\cmd.exe

Mycomputer>properties>Advance System Settings>Environment Variables>System Variables

add this path:enter image description hereComSpec C:\Windows\System32\cmd.exe


The problem for me was that my solution directory was on a different drive than windows. Creating my solution on my C drive solved the issue.