Node binary not found in PATH by IDE, yet shows during `echo $PATH` (Ubuntu Linux)

Viewed 6653

VSCode shows the following alert in a prompt:

Can't find Node.js binary "node": path does not exist. Make sure Node.js is installed and in your PATH, or set the "runtimeExecutable" in your launch.json

In terminal I see an NVM path to node:

$ node --version
v12.18.4

$ echo $PATH
/home/owner/.config/nvm/versions/node/v12.18.4/bin
:/usr/local/sbin:/usr/local/bin:/usr/sbin
:/usr/bin:/sbin:/bin:/usr/games
:/usr/local/games:/snap/bin
// line breaks manually added by me for readability

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

$ npm --version
6.14.6

Does anyone know how to fix this PATH issue?

I suspect the issue is with PATH and not VsCode but am including my launch.json below in case I'm wrong.

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "pwa-node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": [
        "<node_internals>/**",
        "node_modules"
      ],
      "program": "${workspaceFolder}/src/server.ts",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "outFiles": [
        "${workspaceFolder}/compiled/**/*.js"
      ],
      "runtimeExecutable": "node"
    }
  ]
}
Other Attempts to fix this

Restarting Computer - The PATH issue still presented

Adding / removing runtimeExecutable k/v pair from above config file - Also no change

3 Answers

update launch.json with this

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

update "runtimeExecutable" in launch.json to:

        "runtimeExecutable": "your-path/.npm-global/nodemon",

example :

        "runtimeExecutable": "C:/Users/bekir/.npm-global/nodemon",

This is probably not the most elegant solution but I redundantly installed nodejs via terminal and this has fixed the PATH issue

sudo apt install nodejs

The debugger is showing the path to the node binary in the subfolder of nvm so I'm not clear what changes were made, other than it works now.

Related