Home > Net >  Windows Terminal - npm is not responding
Windows Terminal - npm is not responding

Time:10-20

When using the specific combination of Git Bash and Windows Terminal, npm does not do anything. For example, npm -v, npm install, or any other command starting with npm will just go to the next line with no response.

However, when I run npm -v or npm in general on other terminals on my Windows 10 PC, it works fine.

It also works fine in Windows Terminal when using:

  • Git Bash itself
  • PowerShell
  • CMD

I've tried uninstalling and reinstalling a bunch of times to no avail, and I don't believe npm itself is installed incorrectly since it works fine with Command Prompt.

Edit: Windows Terminal settings for Git Bash:

{
 "guid": "{ed985d27-ac7c-477b-a3fc-1f59152f5199}",
 "commandline": "C:\\Program Files\\Git\\usr\\bin\\bash.exe",
 "cursorShape": "filledBox",
 "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
 "name": "Git Bash",
 "startingDirectory": "%USERPROFILE%",
 "tabTitle": "Git Bash"
}

CodePudding user response:

I'm thinking that Windows Terminal may be running Git Bash without picking up part of your startup config, such as ~/.bashrc or ~/.bash_profile`. Git Bash seems to have a slightly different idea of how these should be sourced than "regular Bash", and I'm much more familiar with the normal Linux version.

You mentioned "reinstalling a bunch of times", but my assumption is that you meant Windows Terminal.

I only have about a 25% confidence that this will fix it, but what I'd like for you to try is deleting your Git Bash profile in Windows Terminal, downloading the latest Git Bash, and reinstalling.

The reason for this is that the latest Git Bash includes a JSON fragment extension for Windows Terminal that will create a profile automatically. From the looks of your current profile, I don't believe it was created by Git Bash. The newly installed one should force the shell to launch as a login, interactive shell (-l -i) to make sure that all necessary files are sourced.

You could also try just editing the profile to add -l -i to the bash.exe:

{
 "guid": "{ed985d27-ac7c-477b-a3fc-1f59152f5199}",
 "commandline": "C:\\Program Files\\Git\\usr\\bin\\bash.exe -l -i",
 "cursorShape": "filledBox",
 "icon": "C:\\Program Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
 "name": "Git Bash",
 "startingDirectory": "%USERPROFILE%",
 "tabTitle": "Git Bash"
}

But I'd just try the reinstall of the latest Git Bash, which should set it up automatically.

If this doesn't change anything, some additional things to try:

  • Run which npm in Git Bash both with and without Windows Terminal. Are the results the same or different?

  • Try starting PowerShell in Windows Terminal, then manually run C:\Program Files\Git\usr\bin\bash.exe. Does npm work? If not, try C:\Program Files\Git\usr\bin\bash.exe -l -i to see if that changes anything.

CodePudding user response:

Try to reinstall windows terminal.

  • Related