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.
asked Jun 14, 2016 at 22:30
klewisklewis
7,33715 gold badges56 silver badges100 bronze badges
5
On OSX and VSCode 1.56.2 all I had to do was to close and restart VSCode and the problem went away.
Before you despair git that a try.
answered Dec 18, 2018 at 17:39
David DehghanDavid Dehghan
21.6k10 gold badges107 silver badges94 bronze badges
12
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.
starball
15.1k6 gold badges28 silver badges134 bronze badges
answered Jul 19, 2018 at 13:33
anuj ranaanuj rana
1,0227 silver badges2 bronze badges
2
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.
answered Jul 16, 2016 at 18:25
4
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.
answered Mar 14, 2017 at 14:59
3
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 16
(change 16
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.
answered Apr 9, 2021 at 23:40
SamSam
26.9k12 gold badges73 silver badges101 bronze badges
4
I did which node
on my terminal:
/usr/local/bin/node
and then i added
"runtimeExecutable": "/usr/local/bin/node"
in my json file.
answered May 21, 2019 at 15:46
ASHISH RASHISH R
3,9951 gold badge20 silver badges16 bronze badges
2
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
-
Select
zsh
from the options
answered Jun 11, 2020 at 18:26
So node got kicked out of path. you can do
SET PATH=C:Program FilesNodejs;%PATH%
Or simply reinstall node to fix this. which ever you think is easiest for you
answered Jun 14, 2016 at 22:33
irimawiirimawi
3681 silver badge9 bronze badges
3
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.
Duck Dodgers
3,3798 gold badges29 silver badges43 bronze badges
answered Jan 3, 2019 at 12:15
SebastianSebastian
1812 silver badges4 bronze badges
0
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"
answered Mar 19, 2019 at 10:54
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.
answered Nov 3, 2020 at 9:53
ShlShl
3,0101 gold badge17 silver badges16 bronze badges
I also ran into this error. Restart the PC works for me.
answered Feb 17, 2017 at 13:42
Umair AkbarUmair Akbar
5785 silver badges11 bronze badges
1
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.
answered Jul 10, 2018 at 10:31
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!
answered Apr 20, 2020 at 19:41
3
(CMD+SHIFT+P) Shell command: Install ‘code’ command in PATH
should do the trick!
answered Jul 26, 2021 at 15:12
TellisenseTellisense
1,80812 silver badges11 bronze badges
1
Just relaunch your project from the termial
e.g. yourprojectdir code .
answered Dec 5, 2022 at 7:52
i resolved this problem after disable ESLint
extention.
answered Apr 19, 2020 at 8:11
I am on OSX, this did not work for me:
code . --user-data-dir='.'
but this DID work:
code . -data-dir='.'
answered Apr 19, 2020 at 10:23
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
answered Jun 3, 2020 at 19:39
D.LD.L
4,0324 gold badges22 silver badges43 bronze badges
I also encountered this issue. Did the following and it got fixed.
- Open your computer terminal (not VSCode terminal) and type node —version to ensure you have node installed. If not, then install node using nvm.
- 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"
- If you have multiple bash files, you ensure to add the PATH to all of them.
- Restart your VSCode terminal and it should be fine.
answered Jun 9, 2020 at 4:46
Mine was more project specific. We use «Auto Reload» to run our launch.json for the backend. The error states the file path of the runtimeExecutable
and allows you to open launch.json
. In my launch.json case:
"runtimeExecutable": "${workspaceFolder}/functions/node_modules/.bin/nodemon"
I tried the restarts and answers here originally but no luck, so I manually explored into my functions/node_modules
folder and realized .bin
was missing. I used my terminal to path into functions
like so:
cd functions
Terminal directory path example: ( ~/OneDrive/Desktop/{project dir covered}/{project dir covered}/functions )
Then I did an npm install using npm i
, and now everything is back to normal. Keep in mind, most of these answers are general fixes. If your situtation is more specific, be sure to break it down from the start. Hope this might help others!
answered Jun 22, 2022 at 20:14
В консоли node.js command код запускается, но в терминале vs code ошибка
node : Имя «node» не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличи
е и правильность пути, после чего повторите попытку.
Понятие не имею, что случилось, до этого всё работало
-
Вопрос заданболее трёх лет назад
-
2414 просмотров
@connor4312 , i have received following log (exthost.log) as follows;
[2020-08-30 09:12:25.295] [exthost] [info] extension host started
[2020-08-30 09:12:25.305] [exthost] [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication {"startup":false,"extensionId":{"value":"vscode.microsoft-authentication","_lower":"vscode.microsoft-authentication"},"activationEvent":"onAuthenticationRequest:microsoft"}
[2020-08-30 09:12:25.305] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/microsoft-authentication/dist/extension.js
[2020-08-30 09:12:25.312] [exthost] [info] ExtensionService#_doActivateExtension vscode.github-authentication {"startup":false,"extensionId":{"value":"vscode.github-authentication","_lower":"vscode.github-authentication"},"activationEvent":"onAuthenticationRequest:github"}
[2020-08-30 09:12:25.312] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/github-authentication/dist/extension.js
[2020-08-30 09:12:25.316] [exthost] [info] ExtensionService#_doActivateExtension vscode.typescript-language-features {"startup":false,"extensionId":{"value":"vscode.typescript-language-features","_lower":"vscode.typescript-language-features"},"activationEvent":"onLanguage:javascript"}
[2020-08-30 09:12:25.316] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension
[2020-08-30 09:12:25.324] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"extensionId":{"value":"vscode.debug-auto-launch","_lower":"vscode.debug-auto-launch"},"activationEvent":"*"}
[2020-08-30 09:12:25.324] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/debug-auto-launch/dist/extension
[2020-08-30 09:12:25.325] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"extensionId":{"value":"vscode.emmet","_lower":"vscode.emmet"},"activationEvent":"*"}
[2020-08-30 09:12:25.325] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/dist/node/emmetNodeMain
[2020-08-30 09:12:25.331] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2020-08-30 09:12:25.331] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/main
[2020-08-30 09:12:25.343] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"extensionId":{"value":"vscode.merge-conflict","_lower":"vscode.merge-conflict"},"activationEvent":"*"}
[2020-08-30 09:12:25.343] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/dist/mergeConflictMain
[2020-08-30 09:12:25.344] [exthost] [info] ExtensionService#_doActivateExtension vscode.search-result {"startup":true,"extensionId":{"value":"vscode.search-result","_lower":"vscode.search-result"},"activationEvent":"*"}
[2020-08-30 09:12:25.344] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/search-result/dist/extension.js
[2020-08-30 09:12:25.440] [exthost] [info] ExtensionService#_doActivateExtension vscode.github {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2020-08-30 09:12:25.440] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/github/dist/extension.js
[2020-08-30 09:12:25.447] [exthost] [info] eager extensions activated
[2020-08-30 09:12:32.127] [exthost] [info] extension host started
[2020-08-30 09:12:32.137] [exthost] [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication {"startup":false,"extensionId":{"value":"vscode.microsoft-authentication","_lower":"vscode.microsoft-authentication"},"activationEvent":"onAuthenticationRequest:microsoft"}
[2020-08-30 09:12:32.137] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/microsoft-authentication/dist/extension.js
[2020-08-30 09:12:32.144] [exthost] [info] ExtensionService#_doActivateExtension vscode.github-authentication {"startup":false,"extensionId":{"value":"vscode.github-authentication","_lower":"vscode.github-authentication"},"activationEvent":"onAuthenticationRequest:github"}
[2020-08-30 09:12:32.144] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/github-authentication/dist/extension.js
[2020-08-30 09:12:32.148] [exthost] [info] ExtensionService#_doActivateExtension vscode.typescript-language-features {"startup":false,"extensionId":{"value":"vscode.typescript-language-features","_lower":"vscode.typescript-language-features"},"activationEvent":"onLanguage:javascript"}
[2020-08-30 09:12:32.148] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension
[2020-08-30 09:12:32.157] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"extensionId":{"value":"vscode.debug-auto-launch","_lower":"vscode.debug-auto-launch"},"activationEvent":"*"}
[2020-08-30 09:12:32.157] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/debug-auto-launch/dist/extension
[2020-08-30 09:12:32.158] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"extensionId":{"value":"vscode.emmet","_lower":"vscode.emmet"},"activationEvent":"*"}
[2020-08-30 09:12:32.158] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/dist/node/emmetNodeMain
[2020-08-30 09:12:32.164] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2020-08-30 09:12:32.164] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/main
[2020-08-30 09:12:32.176] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"extensionId":{"value":"vscode.merge-conflict","_lower":"vscode.merge-conflict"},"activationEvent":"*"}
[2020-08-30 09:12:32.176] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/dist/mergeConflictMain
[2020-08-30 09:12:32.177] [exthost] [info] ExtensionService#_doActivateExtension vscode.search-result {"startup":true,"extensionId":{"value":"vscode.search-result","_lower":"vscode.search-result"},"activationEvent":"*"}
[2020-08-30 09:12:32.177] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/search-result/dist/extension.js
[2020-08-30 09:12:32.272] [exthost] [info] ExtensionService#_doActivateExtension vscode.github {"startup":true,"extensionId":{"value":"vscode.github","_lower":"vscode.github"},"activationEvent":"*"}
[2020-08-30 09:12:32.272] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/github/dist/extension.js
[2020-08-30 09:12:32.285] [exthost] [info] eager extensions activated
[2020-08-30 09:12:33.730] [exthost] [info] ExtensionService#_doActivateExtension vscode.configuration-editing {"startup":false,"extensionId":{"value":"vscode.configuration-editing","_lower":"vscode.configuration-editing"},"activationEvent":"onLanguage:jsonc"}
[2020-08-30 09:12:33.730] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/configuration-editing/dist/configurationEditingMain
[2020-08-30 09:12:33.732] [exthost] [info] ExtensionService#_doActivateExtension vscode.json-language-features {"startup":false,"extensionId":{"value":"vscode.json-language-features","_lower":"vscode.json-language-features"},"activationEvent":"onLanguage:jsonc"}
[2020-08-30 09:12:33.733] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/client/dist/node/jsonClientMain
[2020-08-30 09:12:42.489] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-server-ready {"startup":false,"extensionId":{"value":"vscode.debug-server-ready","_lower":"vscode.debug-server-ready"},"activationEvent":"onDebugResolve"}
[2020-08-30 09:12:42.489] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/debug-server-ready/dist/extension
[2020-08-30 09:12:42.491] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.js-debug {"startup":false,"extensionId":{"value":"ms-vscode.js-debug","_lower":"ms-vscode.js-debug"},"activationEvent":"onDebugResolve:node"}
[2020-08-30 09:12:42.491] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/extension.js
[2020-08-30 09:12:42.585] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.node-debug2 {"startup":false,"extensionId":{"value":"ms-vscode.node-debug","_lower":"ms-vscode.node-debug"},"activationEvent":"onDebugResolve:node"}
[2020-08-30 09:12:42.585] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/out/src/extension
[2020-08-30 09:12:42.593] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.node-debug {"startup":false,"extensionId":{"value":"ms-vscode.node-debug","_lower":"ms-vscode.node-debug"},"activationEvent":"onDebugResolve:node"}
[2020-08-30 09:12:42.593] [exthost] [info] ExtensionService#loadCommonJSModule file:///Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug/dist/extension.js
Установил Node.js — скачал архив для Linux с официального сайта. Распаковал по инструкции и добавил путь в PATH — прописал в profile:
# Nodejs
VERSION=v14.16.0
DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
Выполнил обновление profile:
~$ . ~/.profile
Перезагрузил компьютер.
При запуске с основного терминала Linux все работает:
~$ node -v
v14.16.0
~$ npm version
{
npm: '6.14.11',
ares: '1.16.1',
brotli: '1.0.9',
cldr: '37.0',
icu: '67.1',
llhttp: '2.1.3',
modules: '83',
napi: '7',
nghttp2: '1.41.0',
node: '14.16.0',
openssl: '1.1.1j',
tz: '2020a',
unicode: '13.0',
uv: '1.40.0',
v8: '8.4.371.19-node.18',
zlib: '1.2.11'
}
~$ npx -v
6.14.11
Те же команды в терминале VScode дают такой результат:
sh-5.1$ node -v
sh: node: команда не найдена
System: Kernel: 5.4.0-66-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: Cinnamon 4.8.6
wm: muffin dm: LightDM Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal
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.