5

I had the known issue of python freezing in Git bash on windows. Many answers on stackoverflow suggested to use WinPTY.

Which works fine when I use:

winpty python foo.py

But I run a python program as part of a npm script. My package.json has this:

"scripts": {
  "start": "python foo.py && something else"
} 

So I figure I will need to run npm script with WinPTY too:

winpty npm start

But this is not working. I got different error messages on different environments.

  1. I got "Not found in PATH" at work which has latest git and npm installed, but it is in PATH:

winpty: error: cannot start 'npm': Not found in PATH

  1. I got a different error at my personal computer with a slightly older git:

Error 0x2 starting npm start

Any ideas why npm and winpty isn't working together?

If I run npm start without winpty it works fine. winpty node works too.

mehamasum
  • 5,554
  • 2
  • 21
  • 30

1 Answers1

9

I got the same problem. Actually, in nodejs installation folder, there is npm.cmd So what you should do to start npm using winpty is

winpty npm.cmd install
wanyancan
  • 370
  • 3
  • 8
  • 1
    for my own reference in 3-6 months `env PYTHON=/c/Python27/ winpty npm.cmd install` is the full command to also change the default python so that node-gyp works. – Josh Peak Jun 17 '19 at 23:09