-2

I'm running a local server on localhost through VS Code using nodemon on my mac. So everytime I save, the server restarts and updates. My problem is that VS Code always switches window to my browser when the server restarts, so my flow gets interrupted. There must be a way to prohibit VS Code from opening my browser, or at least not doing it at every restart of server?

2 Answers2

0

Look into script your nodemon runs when it's watcher detects change and locate call that starts the browser there: presumably you have one in your "start server" script.

It would probably involve your local server address and call like require('child_process').exec(); see How to use nodejs to open default browser and navigate to a specific URL.

myf
  • 9,874
  • 2
  • 37
  • 49
0

I kind of solved it by adding "BROWSER=none" so my start script (which otherwise only said "nodemon server.js"). But then the browser won't refresh automatically and I'm still curious what's causing it.

Dharman
  • 30,962
  • 25
  • 85
  • 135