I run different node versions to build different web apps on my machine. I use nvm to manage the environments.
I set the integrated terminal in VS Code for osx to zsh as so:
"terminal.integrated.shell.osx": "/bin/zsh",
In the integrated terminal It appears to be running zsh, my nvm config runs etc.
But when I run the VS Code Debugger it doesn't pick up my nvm version.
When I run echo $SHELL in the integrated terminal I get /bin/bash even though it appears to be running /bin/zsh. In iTerm2 i get /bin/zsh as expected.
I need the debugger to run in zsh so that the nvm config is picked up and the build step is run in the correct node version. Otherwise node-sass has a fit etc and my debugging environment is out of whack with dev and prod.
How can I get the VS Code dubugger to run in zsh?
BTW: I am using the chrome debugger extension which appears to disallow the out-the-box node version debugger config such as "runtimeVersion": "9.4.0".
Add next to your settings.json, respecting your OS.
This covers both normal and debug terminals
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "zsh",
"args": []
}
},
"terminal.integrated.defaultProfile.osx": "zsh"
Related
I have an issue on node.js debugging on vscode, it no matter what I do persists on a particular node.js version on nvm.
lets say I have the following simple launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "webpack launch",
"program": "npx",
"args": [
"webpack",
"serve",
"--config",
"config/webpack.config.dev.js",
"--port",
"3051",
],
"autoAttachChildProcesses": true,
"stopOnEntry": true
},
note: this has been working completely fine until I recently changed nvm version mainly I use and on an other computer.
if you run the above "webpack launch" debug, in the debug console, it shows:
/home/user/.nvm/versions/node/v13.10.1/bin/node npx webpack serve --config config/webpack.config.dev.js --port 3051
well, I'm not using v13.10.1 anymore, but v17.9.0. I'm saying this for a countless times, vscode. lets do the steps I'm doing to tell vscode to not to use the old version but the v17.9.0 version:
.bashrc
added nvm use v17.9.0 in the last line
nvm alias default
ran nvm alias default v17.9.0
.nvmrc
added nvm use v17.9.0 in ~/.nvmrc
reload/re-launch vscode
reload vscode and/or quit vscode then restart vscode.
check in the terminal
check if nvm working by checking its version on the newly opened vscode instance terminal.
$ nvm current
v17.9.0
$ node -v
v17.9.0
re-try the debug
the same. wow.
/home/user/.nvm/versions/node/v13.10.1/bin/node npx webpack serve --config config/webpack.config.dev.js --port 3051
Process exited with code 1
What tf is going on with vscode? What am I missing here, may I know? Thanks.
I have checked and found out my vscode is reflecting the same version I am changing from the terminal outside the vscode terminal. SO it's working for me let's try some steps for you to fix this problem:
Restart the vscode (which you have already tried). Also restart the pc and check.
Uninstall the older version of node i.e. v13.10.1 if you are not using it again.
Last option is to uninstall vscode and install the latest version of vscode if possible.
There are lots of this kind of scenerios when vscode terminal don't reflect the changes but it gets fixed by just restarting the terminal again in vscode which is not happening in your case.
But I hope these 3 steps will help you to get it fixed.
I have noticed that conda activate environment stopped working in vscode integrated terminal with no obvious reason (I certainly did not install any new extensions, nor updated conda or vscode in the last few days).
Expected behaviour
After running conda activate environment I want the environment to be activated and be capable of using the environment python interpreter. Essentially it should look like this:
(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/Users/lpravda/anaconda3/envs/rdkit-env/bin/python
This is what I can achieve using non-vscode terminal and work with conda as usual.
Actual behaviour
This happens when I type in the same set of commands in vscode integrated terminal:
(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/usr/local/bin/python
The environment seems to be switched on, however python still points to the system install python 2.7 and I have no idea why.
It used to be working like for years and now it broke down.
Note: When I run debugger in vscode the correct conda environment is selected and executed.
My setup:
OS: Mac OS X: 10.14.3
vscode: 1.31.1
conda: 4.6.7
Update
ongoing issue with the following update:
OS: Mac OS X: 10.14.3
vscode: 1.33.3
conda: 4.6.8
Any idea what could possibly broke down?
it is issue which you can read about it here, but I find this solution
which solve the issue in this version. Also, as community said the problem with python interpreter and env gonna fix in next major update.
Create an workspace folder
Inside the create file post the following code:
{
"folders": [
{
"path": "."
}
],
"settings": {
"python.condaPath": "/home/pcuser/anaconda3/condabin/conda",
"python.pythonPath": "/home/pcuser/anaconda3/envs/my_env/bin/python",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
}
}
Save configuration and close vscode
Open vscode.
It will select automatically the conda enviroment (Should appear at the bottom left of vscode). Inside terminal 'my_env' will also be selected. If vscode doesn't select the 'Python Selected Interpreter' before you open the terminal the my_env inside terminal won't be selected. Open the terminal after the my_env is selected by vscode
I have managed to get the integrated terminal working with msys (bash) terminal using the following settings:
"terminal.integrated.shell.windows": "C:\\msys64\\bin\\msys_shell.cmd",
"terminal.integrated.shellargs.windows": "-mingw64 -defterm -nostart",
"terminal.integrated.env.windows": "HOME": "${workspace Folder}"
And this works well. I had to add the env "HOME" entry to get the sh to start in the correct home directory as it wouldn't work with (or with nothing at all):
"terminal.integrated.cwd": "${workspaceFolder}"
Now I have run into another problem. While the above settings work perfectly for a terminal window they fail for the build task. So I am forced to manually "make" from the integrated terminal window.
It fails with with error:
/d: /d: is a directory
My environment is Windows 10 msys64 mingw64.
Any ideas appreciated!
I ran into the same issue today. On their help page for tasks.json they talk about the options fields in the settings.
VSCode uses the default shell for tasks unless you tell it not to. Additionally you'll have to pass your command to the resulting shell. I solved that using -shell bash -c so bash runs the command immediately.
The syntax is something like this:
"command": "make -j8",
"options": {
"shell": {
"executable": "C:\\msys2\\msys2_shell.cmd",
"args": ["-defterm", "-mingw64", "-no-start", "-here", "-shell bash -c"]
}
}
I have installed nodemon by: sudo npm install -g nodemon. With MacOS Terminal, i can run nodemon command.
But in Integrated Terminal of Visual Studio Code, I can't run nodemon and I don't know why.
Maybe two terminals don't sync ?
Help me, please.
In my case
changed the default shell from Powershell to CMD
restart VSCode.
VSCode now started with cmd chosen as the default, and the problem didn't happen with cmd.
Shutdown VS Code and launch it again from the command line with 'code .'.
Above approach should fix the issue. Sometime when we install node after installing visual studio some sort of environment variable path issue happens.
Looks like this has been asked by others. But here is a possible solution. In you package.json edit scripts:
"scripts": {
"serve": "nodemon server.js"
},
then npm run serve
You can also check you bash profile
if nodemon is not being found by bash.
~/.bash_profile
add
PATH=$PATH:/usr/local/bin/bin/
Check this solution
and this discussion here
I was also facing a similar problem for a long time during my web development. If you are also facing these problem in VS code, so I recommend you to install Powershell Extention in your vs code or update your Powershell Extention. And restart your vs code.
I have setup my integrated terminal to be bash as shown below:
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
Bash is working but when I try to run things like npm, node, ect it says the command is not found. If I run the standalone git bash.exe (not the one in the bin folder) it works correctly but you have to run the one in the bin folder to have it integrated, what do I need to do to fix it?
Add "terminal.integrated.shellArgs.windows": ["--login","-i"] to your settings. You may have noticed git bash.exe runs with these arguments.
I had a similar issue (missing arguments) when setting up an integrated terminal with Visual Studio - although I haven't had a problem with VSCode.