Skip to content
Advertisement

Visual Studio Code: Run node script on save

I use Visual Studio Code (1.8.1) to write ECMAScript 6 for NodeJS 7.3 (so currently no TypeScript).

I want to run the current script with node from the command line (node ${file}) every time the script file is saved. Is this possible?

To be clear: NodeJS is not running as server, but used for executing cli scripts.

Advertisement

Answer

You can use ‘run-when-changed’ module to achieve this.

You can use it like:

run-when-changed –watch “src/**” –exec “npm run build”

This will watch file changes in src folder and execute npm build script.

link: https://www.npmjs.com/package/run-when-changed

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement