I love the new Visual Studio Code editor/IDE. It’s fast, simple, lightweight, and an overall pleasure to work with. I love being able to just “open a folder” and work with files directly – all while getting great intellisense.
> node index.js
So I don’t need debugging. I want to execute Node against whatever file I have opened at the moment. It turns out this was not built-in – but the good news is that it was not difficult to add the functionality.
First, Ctrl+Shift+P to bring up the Command Palette. Then you want to type “Configure Task Runner”. That will open a “tasks.json” file which it will create in a local “.settings” directory. Inside there is a default TypeScript task along with a bunch of commented out tasks to show example of running on commands like gulp, MSBuild, etc. (and yes, just pretend that JSON actually has comments). You can remove everything in this file and just add:
Yes, of course, I can just go over to a console window and type: “node index.js” as I’ve always traditionally done. But this makes it even easier/faster and let’s me stay within my IDE. Plus, this will always work against whatever file I happen to have opened at the time.
One bizarre thing I’ve found is that I don’t (yet) see any way to add multiple tasks to the “tasks.json” file - there does seem to be a way to add multiple tasks for a single command, but not multiple tasks for different commands. Hopefully, this will be a feature that is addressed in new versions of VS Code.