1

I'm using Node.js to make a build system in Sublime Text 2 to build JavaScript code. I know how to setup basic build systems in Sublime, but this one is really giving me problems.

JavaScript example code:

var end = 10; for (var i = 0; i < end; i++) { console.log("hello world!"); }; 

1st try:

 { "cmd": ["node", "$file"] } 

returned this in the console: [Finished in 0.1s]

2nd try:

{ "cmd": ["node", "$file", "$file_base_name"], "working_dir": "${project_path:${folder}}", "selector": "#.js" } 

returns the same thing.

Any help would be much appreciated (I've spend over 2 hours searching google).

EDIT: Fixed For to for : Same result.

2
  • Could it be a syntax error due to the uppercase F in For? Commented Sep 3, 2013 at 2:24
  • Just changed it to for from For and still same results. Commented Sep 3, 2013 at 2:27

2 Answers 2

2

Here's a Javascript build system I use on my Mac with Sublime Text. It uses the Webkit engine (SquirrelFish) which comes with OS X, and therefore doesn't require anything special be installed (not even Node.js):

{ "cmd": ["/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc", "$file"], "selector": "source.js" } 

Tips:

  1. Use "print(foo)" from within your script to return results to the Sublime console
  2. Save your .js file to disk at least once
  3. If ".js" files are not automatically selected, ensure you have no other build systems for ".js" in "~/Library/Application Support/Sublime Text 2/Packages/". Alternately you can manually select the appropriate system from "Tools > Build System"

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

1

In Sublime Text 2 you must save your .js file before you build, or the result above will happen.

Simple fix is to save the file (obviously)!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.