I can't run nodemon from Integrated Terminal of Visual Studio Code Mac OS - visual-studio-code

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.

Related

sudo command is not working in Vscode terminal

I am using vscode in Linux Mint.
"sudo, root, npm" commands are not working in Vscode bash terminal. I can only use cd, ls and install commands.
yearmfew#mySpace:~/jules/clr-6$ npm
bash: npm: command not found
It was because of flatpak. I have vscode from there installed. It is officially distributed in snap. I have downloaded from there and it is okay now.
This is explained in the documentation for VS Code : https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration
(which has various options), but to avoid this being a link-only answer:
Set the "terminal.integrated.shell.windows" VS Code configuration variable to "C:\Windows\System32\bash.exe" and you should be good to go.
For convenience, there's also a Select Default Shell command in the command palette which sets this for you.

nvm and gulp found on Visual Code terminal but not on linux terminal

I have Ubuntu LTS 20.04 running on wsl2 in Windows, this way I'm able to compile my JS/React code and run my php server in linux and use windows to code using Visual Studio Code.
This is running great, but a strange thing is happening, I installed nvm and gulp through the Visual Studio Code terminal and if I use them on the terminal it works fine but not if I do it outside the terminal (using Windows terminal), it says not found for both gulp and nvm.
I assume VSCode is adding a few things to the PATH but I don't know what to do for them to be found by the windows terminal (outisde VSCode terminal). Screen below. On the left is the result of running nvm list inside VS Code terminal and on the right on Ubuntu terminal, which can't find.
I'm a bit confused by your question. It sounds like you're installing programs on Windows through the VSCode terminal, and then trying to run them on Windows but it's not working. But then your screenshot shows the WSL Ubuntu prompt failing to find the command. Assuming you want to run these under WSL, log in to WSL Ubuntu and run this:
find / -name nvm
If you actually want to use the Windows terminal to run the program, you'll have to find where it is installed in Windows and make sure that's in your %PATH% but this doesn't seem like it's what you're trying to do.
The correct answer was provided by the comment from MindSwipe.
On VSCODE terminal if I "echo $PATH" it has the nvm directory in it while the $PATH on WSL doesn't, I assume VSCODE alters its own terminal PATH when the tools are installed using it instead of the global WSL path.
I've changed the WSL path and it's now working, how can I present the bounty to MindSwipe ?

Could not install typings files... in VS Code, with Bash on Ubuntu on Windows

I'm trying to use Visual Studio Code with Bash on Ubuntu on Windows. I have VS Code installed on Windows, but otherwise use Bash exclusively for my JavaScript development workflow.
I have node and npm installed on Bash (via apt-get), however, I do not have node and npm also on Windows to avoid duplication. In my VS Code settings, I have configured the integrated shell to use Bash:
"terminal.integrated.shell.windows": "C:\\windows\\Sysnative\\bash.exe"
The integrated shell works fine, and node and npm are both accessible. However, when I launch VS Code on my project, I get the warning:
Could not install typings files for JavaScript langauge features. Please ensure that NPM is installed or configure 'typescript.npm' in your user settings
I have tried both the following settings, neither of which work:
"typescript.npm": "C:\\windows\\Sysnative\\bash.exe"
"typescript.npm": "C:\\windows\\Sysnative\\bash.exe -c \"npm\""
Is it possible to get VS Code to install typings files via the npm that is installed on Bash?
Try setting “externalTerminal.windowsExec”: “bash” in your settings file to set it as the terminal executable and then restart VS Code

Unable to run npm, node from bash in VSCode

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.

VS Code doesn't add command line on path permanently on Mac

I am using VS code 1.8.1 on Mac 10.12.3 (16D32). After launch vscode, I run cmd shift p to open command search field. Then run Install code command in Path. I can see the code got added on PATH but it got removed after I close vs code. Is there a way to add it permanently?
So I've just had this issue during setup of a new laptop and found a simple (but slightly embarrassing) solution that worked for me. After faffing about with it for way too long I noticed I had left it in Downloads. I moved the .app file to /Applications and ran the command-line install function again and now the "code" command persists.
Add this to your ~/.bash_profile
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
source: https://code.visualstudio.com/docs/setup/mac
I am assuming you've checked this link.
VSCode application generally resides in /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code.
Follow these steps to access VSCode through code on shell.
Open bash_profile page
sudo vi /etc/paths
Add an extra line in the list of PATH folders as
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/
Exit from vi: Esc > :wq! > Enter Key
Restart shell. Then do echo $PATH to confirm VSCode has been added successfully.
Check code command is added by typing which code. You should see VSCode path printed on screen.
Try this link if it doesn't work out.
Edit: I am using version 1.9.1 and after I ran Install code command in Path it got added permanently.
Visual Studio Code
rm /usr/local/bin/code
ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
Visual Studio Code - Insiders
rm /usr/local/bin/code-insiders
ln -s "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code" /usr/local/bin/code-insiders
For Big Sur:
From the official docs:
Note: Since zsh became the default shell in macOS Catalina, run the
following commands to add VS Code to your path:
cat << EOF >> ~/.zprofile
# Add Visual Studio Code (code) export PATH="\$PATH:/Applications/Visual Studio
Code.app/Contents/Resources/app/bin" EOF
I did this and it worked for me.
I am running Visual Studio Code - Insiders 1.23.0 on a Mac/Mac OS 10.10.5 Yosemite. I added the "Shell Command: Install 'code-insiders' command in PATH" from within VSC - Insiders. From the terminal in any directory I just add 'code-insiders .' and it launches in VSC - Insiders without issue.
Hope that helps.
For me, the problem was that Visual Studio Code.app was not in the Applications folder, but rather in the Downloads folder. Moving it there and re-running the add to path command fixed it for me.