Visual Studio: Cannot find runtime 'node' on PATH

Visual Studio code error: Cannot find runtime 'node' on path Error.


If you are working on NodeJS  Project and using Visual Studio Code as your IDE.
Visual Studio Code provides debugging NodeJS application feature as well.

To Run Debugger you just need to Select Debugger from Menu and start debugging.   

But if you are using nvm on your machine then it may happen that you are using the different version to run node application and Visual Studio Code uses different node version.

Sometimes Visual Studio Code doesn't find node so it will throw the following error.




And if you see the launch.json file it will look like below.

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}


Now we just need to add one line so it will find the node path.



{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"runtimeExecutable": "/home/user/.nvm/versions/node/v10.6.0/bin/node",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}


So as you can see I have added the following line in json file.


"runtimeExecutable": "/home/user/.nvm/versions/node/v10.6.0/bin/node",

So same way you can find the your current node version and can give the explicitly path to it.

If you are using NVM as node versioning manager then do the following steps to provide the exact path.

  • Find out your current nvm version by running nvm current 
  • then give path as follows
    • /home/{user}/.nvm/versions/node/{nvm current node version}/bin/node
Thats it you are done with it.

Now again click on the debugger and start debugging.

Happy debugging !!!!


Please comment out if you are facing any issues with it.

Visual Studio: Cannot find runtime 'node' on PATH Visual Studio: Cannot find runtime 'node' on PATH Reviewed by Vikas Kad on Monday, September 10, 2018 Rating: 5

No comments:

Powered by Blogger.