Skip to content

Troubleshoot ' 4058 ENOENT' error from NodeJS ‐ Python interpreter cannot be found

Courtney Webster edited this page Oct 31, 2023 · 5 revisions

There are a few known causes for such an error when launching a process using NodeJS:

  Error: spawn <configured shell> ENOENT
	at ChildProcess._handle.onexit (node:internal/child_process:283:19)
	at onErrorNT (node:internal/child_process:478:16)
	at process.processTicksAndRejections (node:internal/process/task_queues:83:21)] {
  errno: -4058,
  code: 'ENOENT',

You could be facing this issue due to your environment variables being misconfigured. Please see below for some potential fixes.

Comspec variable

Make sure ComSpec points to the correct value. Usually, it should point to ComSpec=C:\WINDOWS\system32\cmd.exe. You can check this by opening Command Prompt (cmd) either in VS Code, by opening Command Prompt via the terminal, or outside VS Code, by searching for "Command Prompt" in the start menu.

open-cmd

Once you have a cmd open, type set Comspec:

image

You can also check and edit the value of ComSpec through the environment variable UI. In the start menu type 'environment`, and you should get this option image

Navigate to Advanced -> Environment Variables...: image

Find the ComSpec variable in the System Environment variable section. Make sure it is set to C:\WINDOWS\system32\cmd.exe or something similar. If it is not, click Edit and browse your directories to set it to the correct value. image

Make sure to then close and re-open all instances of VS Code ⚠️ DO NOT RESTART YOUR COMPUTER ⚠️ as you may not be able to log in again if ComSpec is set to an incorrect value.

Path variable

If your ComSpec variable points to the correct value, your Path variable might be missing certain directories such as C:\WINDOWS\system32. You can check this by opening Command Prompt (cmd) either in VS Code, by opening Command Prompt via the terminal, or outside VS Code, by searching for "Command Prompt" in the start menu. Once you have cmd open, type set PATH:

image

This is what it typically looks like:

image

Notice that C:\Windows\System32 is the first entry.

Similar to before, navigate to Advanced -> Environment Variables... in your system environment variable UI. Select the PATH environment variable under system variables and click Edit.

environment_variable_path

In the edit view, make sure that system32 is at the top of the list. You can click the system32 entry and move it up as needed.

edit_environment_variables

Fix that, then close and re-open all instances of VS Code.

Previously reported issues on this

  • Due to incorrect ComSpec: issue
  • Due to incorrect Path: issue
Clone this wiki locally