Nodejs: setup your IDE with Sublime Text Editor 2

Thursday, 29 September 2011 22:05 by myro

If you are considering to develop in nodejs, you should really try Sublime Text Editor 2 with the follwing build setup to let you  easly build your node projects.
Sublime Text Editor 2 has a really customizable build system which lets you personalize the way you build your projects.  If you configurate it correctly, you will be able to launch your node,js applications just pressing [Ctrl] + [B]. 

  1. run Sublime Text Editor
  2. Under Tools > Build System > press New Build System...
  3. Paste this:
    {
      "cmd": ["nodeBuild", "$file"],
      "selector" : "source.js",
       "path" : "/home/myoArch/Bin"
    }

    Please note that  /home/myoArch/Bin is just my path where I personally prefere to store my sh scripts. You should use /usr/lib or whatever you want. 
  4. Press [Ctrl] + [S] to save the file and name it Node. This operation creates a new file under: 
    /home/myoArch/.config/sublime-text-2/Packages/User/Node.sublime-build
  5. Create a new file under /home/myoArch/Bin and name it nodeBuild. This is going to be our launcher script.
  6. Open the file with your editor
  7. Paste this:
         #!/bin/sh
         /usr/bin/killall node
         /usr/bin/node $1
    and save the file.
    Please note again that /usr/bin/node is my path where I have installed the node executable. Always use your paths, not mines!
    As you can see, in this script, I always kill all Node istances that are running before launching a new one, In this way  Ican just press [Ctrl] + [B] to re run my application.
  8. At the last point, just make the file runnable: chmod +x nodeBuild

There you go.. Now you can set up your Build System as Node into Sublime Text Editor and run your node application by pressing [Ctrl] + [B].

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   NodeJs
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed
If you consider this post usefull for your purposes, please consider visiting my sponsors to help me out with the myrocode.com maintenance. Thank you.