title: Have npm watch files in background to enable integration with Visual Studio Task Runner
body: <p>I am trying to have npm watch for file changes in my client side code. I can have it work from the command line ok but I'd really like it to work from Visual Studio task runner.</p>
  
  <p>my package.json looks something like this:</p>
  
  <pre><code>...
  "watch": {
    "compile": {
    "patterns": [
        "wwwroot"
      ],
      "extensions": "ts"
    }
  },
  "scripts": {
    "prebuild": "copyfiles -f ./node_modules/d3/build/*.js ./wwwroot/lib/d3",
    "compile": "tsc &amp;&amp; browserify ./wwwroot/app/app.js -o ./wwwroot/bundle.js",
    "build": "npm run compile",
    "watch": "npm-watch"
  },
  ...
  </code></pre>
  
  <p>So running <code>npm run build</code> then <code>npm run watch</code> from the command line has everything running as expected.</p>
  
  <p>When I use the Task Runner however to bind my watch script to the After Build event like this:</p>
  
  <p><a href="https://i.stack.imgur.com/dMGaY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dMGaY.png" alt="task runner screengrab"></a></p>
  
  <p>it never 'exits' and, as such, the build never completes* and Visual Studio waits for me to kill the task before the application runs. Is there a way to have the script run in the background or some kind of 'detached' mode to enable Visual Studio to complete the build and run the application?</p>
  
  <p>I tried using different watch tools but can't find any such option in any of them.</p>
  
  <p><sub>*Actually, I guess the <em>build</em> itself probably DOES complete but VisualStudio never runs the app and just hangs waiting on the script exiting.</sub></p>