justZito
justZito

Reputation: 559

Run Node script from Sublime Text 2, is it possible?

I am just starting with SubLime Text 2, so when I create a javascript file can I just run node app.js from the sublime console or do I have to do it outside of sublime?

Upvotes: 1

Views: 926

Answers (2)

Dave Mackintosh
Dave Mackintosh

Reputation: 2796

Sorry to add another answer to this but you can use the built in build system to run any kind of command you want from your editor by pressing Ctrl + B (Cmd + B) without installing any plugins.

Go up to Tools -> Build System -> New Build System

And the structure of this file should be something like this

{
  "shell_cmd": "node myapp.js" // Replace with whatever you want to do
}

Save it in the default place.

You also still have the ability to ctrl + c to kill running commands. The downside to this method is you don't get any kind of terminal colouring so if you're using any custom themes on your terminal, you'll only see escape sequences in this window.

The other caveat is it saves files on build by default, you can turn this off in the Tools menu if you don't like this behaviour.

Upvotes: 2

dark_ruby
dark_ruby

Reputation: 7865

Have a look at this (Shell-Turtlestein) extension for sublime text 2, this is basically a shell in your text editor, provided that you change into directory where your node script is located you can run it, and observe any output.

press Ctrl + Shift + C (Cmd + Shift + C) to open a prompt

Upvotes: 0

Related Questions