Cannot find runtime 'node' on PATH - Visual Studio Code and Node.js

node.jsVisual Studio-Code

node.js Problem Overview


With a downloaded and installed version of Visual Studio Code 1.2.1, and a 64bit version of node.exe msi placed in my working directory (I am assuming that is correct), how do we add node and npm command line tools to be on our PATH? I am confused in understanding that statement. Where and how do we implement that? I am quoting this requirement directly from the top of this resource page - https://code.visualstudio.com/Docs/runtimes/nodejs

As a result of my current situation, I set a break-point in an app.js file. And when I hit F5, it tells me...

Cannot find runtime 'node' on PATH 

I am completely lost in understanding and fixing this issue in Visual Studio Code.

node.js Solutions


Solution 1 - node.js

On OSX and VSCode 1.56.2 all I had to do was to close and restart VSCode and the problem went away.

Solution 2 - node.js

first run below commands as super user sudo code . --user-data-dir='.' it will open the visual code studio import the folder of your project and set the launch.json as below

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/app/release/web.js",
            "outFiles": [
                "${workspaceFolder}/**/*.js"
            ],
            "runtimeExecutable": "/root/.nvm/versions/node/v8.9.4/bin/node"
        }
    ]
}

path of runtimeExecutable will be output of "which node" command.

Run the server in debug mode cheers

Solution 3 - node.js

To follow up, I just ran into this as well. When I installed Node.js there was an option that said Add to PATH (Available After Restart). Seems like Windows just needs a restart to make things work.

Solution 4 - node.js

Quick fix that works for me. Navigate to the root directory of your folder from command line (cmd). then once you are on your root directory, type:

code . 

Then, press enter. Note the ".", don't forget it. Now try to debug and see if you get the same error.

Solution 5 - node.js

I did which node on my terminal: /usr/local/bin/node

and then i added "runtimeExecutable": "/usr/local/bin/node" in my json file.

Solution 6 - node.js

Apply a Default Node Version via NVM

I'm using macOS Big Sur and setting the default version via nvm fixed this for me by running this command: nvm alias default 14 (change 14 to the version you want as your default).

Note that node worked fine in the terminal for me (both with zsh and bash) but not when running via the vscode debugger and I already had the following config in both ~/.zshrc and ~/.bash_profile to load in nvm:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

It wasn't until I set the default Node version that vscode would launch node targets just fine.

Solution 7 - node.js

So node got kicked out of path. you can do

       SET PATH=C:\Program Files\Nodejs;%PATH%

Or simply reinstall node to fix this. which ever you think is easiest for you

Solution 8 - node.js

For me, the node binary is in PATH and I can run it from the terminal (iTerm or Terminal), and the Terminal apps are set to use zsh

If you are on a Mac, with iTerm and Zsh, please use the following VSCode settings for Node to work.

After this change, you can get rid of this line from your launch.json config file. (the debug settings in VSCode)

    "runtimeExecutable": "/usr/local/bin/node"

If this doesn't work, make sure you choose the default shell as zsh. To do this,

  • Open the command palette using Cmd+Shift+P

  • Look for the Terminal: Select Default Shell command enter image description here

  • Select zsh from the options enter image description here

Solution 9 - node.js

Had the same issue and in my case it was a problem with a vs code extension. Try running code as:

$ code --disable-extensions

Once in the editor, I ran my program in the debug mode and worked, and then started code with

$ code

And it continued working fine.

Hope it works for you.

Solution 10 - node.js

I had a similar issue with zsh and nvm on Linux, I fixed it by adding nvm initialization script in ~/.profile and restart login session like this

export NVM_DIR="$HOME/.nvm" 
 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm 
 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Solution 11 - node.js

I use /bin/zsh, and I changed vscode to do the same, but somehow vscode still use the path from /bin/bash. So I created a .bash_profile file with node location in the path.

Simply run in terminal:

echo "PATH=$PATH
export \$PATH" >> ~/.bash_profile

Restart vscode, and it will work.

Solution 12 - node.js

I also ran into this error. Restart the PC works for me.

Solution 13 - node.js

The cause for me receiving this error was trying the new pre-release VSCode JS debugger.

If you opted in, change via User settings:

    "debug.javascript.usePreview": true|false

Everything in my normal configuration and integrated terminal was correct and finding executables. I wasted a lot of time trying other things!

Solution 14 - node.js

Do not launch the VS code from the start menu separately. Use

> $Code .

command to launch VS code. Now, create your file with the extension .js and Start debugging (F5) it. It will be executed.

Otherwise, restart your system and follow the same process.

Solution 15 - node.js

i resolved this problem after disable ESLint extention.

Solution 16 - node.js

(CMD+SHIFT+P) Shell command: Install 'code' command in PATH

should do the trick!

Solution 17 - node.js

I am on OSX, this did not work for me:

code . --user-data-dir='.'

but this DID work:

code . -data-dir='.'

Solution 18 - node.js

This is the solution according to the VS code debugging page. This worked for my setup on Windows 10.

"version": "0.2.0",
"configurations": [
{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "program": "${file}"
}

The solution is here:

https://code.visualstudio.com/docs/editor/debugging

Here is the launch configuration generated for Node.js debugging

Solution 19 - node.js

I also encountered this issue. Did the following and it got fixed.

  1. Open your computer terminal (not VSCode terminal) and type node --version to ensure you have node installed. If not, then install node using nvm.
  2. Then head to your bash file (eg .bashrc, .bash_profile, .profile) and add the PATH:
 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm 
 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
  1. If you have multiple bash files, you ensure to add the PATH to all of them.
  2. Restart your VSCode terminal and it should be fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionklewisView Question on Stackoverflow
Solution 1 - node.jsDavid DehghanView Answer on Stackoverflow
Solution 2 - node.jsanuj ranaView Answer on Stackoverflow
Solution 3 - node.jsMichael P. ScottView Answer on Stackoverflow
Solution 4 - node.jsEdson H PhilippeView Answer on Stackoverflow
Solution 5 - node.jsASHISH RView Answer on Stackoverflow
Solution 6 - node.jsSamView Answer on Stackoverflow
Solution 7 - node.jsirimawiView Answer on Stackoverflow
Solution 8 - node.jsAditya Vikas DevarapalliView Answer on Stackoverflow
Solution 9 - node.jsSebastianView Answer on Stackoverflow
Solution 10 - node.jssalamaashoushView Answer on Stackoverflow
Solution 11 - node.jsShlView Answer on Stackoverflow
Solution 12 - node.jsUmair AkbarView Answer on Stackoverflow
Solution 13 - node.jsSean Patrick MurphyView Answer on Stackoverflow
Solution 14 - node.jsSourav DebnathView Answer on Stackoverflow
Solution 15 - node.jsKasra KaramiView Answer on Stackoverflow
Solution 16 - node.jsTellisenseView Answer on Stackoverflow
Solution 17 - node.jsPauls BebrisView Answer on Stackoverflow
Solution 18 - node.jsD.LView Answer on Stackoverflow
Solution 19 - node.jsObinna NnenanyaView Answer on Stackoverflow