1

When I run npm commands on my Windows 10 machine, new processes seem to spawn in new windows.

On my (Mac-using) colleagues machines, I see that these commands run in the same terminal window from which they were called. This is the behaviour I'd expect and is much more useful - it's really hard, for instance, to see my test results in the split second between them finishing and the terminal window being closed!

As an example, our packages.json has a script to run jest:

scripts": {
    "test": "jest"
}

When I run npm run test, the following gets written to the current terminal:

$ npm run test

> @headuplabs/mobile@0.0.1 test C:\Users\TomWright\Documents\Repos\HeadUp.Mobile
> jest

But the actual execution of jest then gets started in a newly created window:

Really exciting screenshot...

I'm using "git bash" as my default integrated terminal in VS Code, but I'm able to replicate this using cmd.exe and outside VS Code (i.e. by running git bash or cmd standalone).

I presume that my npm installation is improperly configured, but my Google search haven't yielded any answers.

Does anyone know what I'd need to do to make npm processes run in the same terminal window?

Tom Wright
  • 11,278
  • 15
  • 74
  • 148

1 Answers1

0

As mentioned in "how to set shell for npm run-scripts in windows", you might want configure the shell in npm itself:

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

That would avoid the default setting, which can trigger a new shell window.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250