Finished yesterday, "Sublime Text 2."Greening and Han-hua [Windows Chapter], today we say how to use St directly run JS Bar. The small group of partners has been to my ST can directly run JS feel very curious, today I will publish this "secret" it. In fact, it is very simple to configure a compilation system. But what is the compiling system and how is it configured? I'll teach you one step at a later stage. (It seems like someone told me that there are some plugins that can be implemented, but there are still noedjs.) PS: In fact, Microsoft also has the realization of JS called Jscript,windows can be based on WSH operation, but still nodejs to force. First of all, we download Nodejs This is necessary, as a qualified front-end, swollen can not have node? Even if you don't use it, it's great to have a load-up force. If you touch this thing for the first time, always click Next to install it. We open cmd to see if we can install successfully. Do you remember how to open cmd? Win+r or click StartRun input cmd. then enter node-V to see if the installation was successful. See a version number stating that the installation was successful and that it will work correctly. Next Open your Artifact ST bar. Select Menu Tools--Build System--NewBuild System ... The Chinese version is a tool.--Compile the system--New Build system ... Then write the following: text {"cmd": ["Node", "$file"], "File_regex": "^[]*file \" (...) \ ", line ([0-9]*)], "Working_dir": "${project_path:${folder}}", "Selector": "Source.js", "Shell":true, "Encoding": "Utf-8", "Windows": { "cmd": ["taskkill/f/im node.exe >nul 2>nul & Node", "$file"] }, "Linux": { "cmd": ["Killall node; Node "," $file "]}} and then save as Javascript.sublime-build, save location by default. Now, let's try a new test.js on the desktop, write a simple test code and press Ctrl+B or F7 run. It worked.. In fact, there are many online tutorials, but many friends said a little bit of a problem, such as must choose just the new JavaScript compiler system to execute. In fact, because many places on the internet"Selector": "Source.js", written "selector": "Source.javascript", so that he cannot automatically select the compiled system based on the suffix name. There are many people running after the result is garbled, in fact, this problem is not easy to explain. But I can tell you how to tune it. See"Encoding": "Utf-8", this, now it's utf-8.If you encounter garbled situation, change to GBK can. Well, the water today, because to help friends to see a problem, so it is. There is a problem, or where the wrong point, please follow the thread. Have friends encounter after execution output [Decode error-Output Not Utf-8][finishedinch1.0s withExit code 1This error means that the output is not UTF.-8, change to "encoding": "GBK"See what went wrong. Different error handling methods are different. This error is often caused by errors in the console. If you're ST3, I suggest you change it."cmd": ["taskkill/f/im node.exe >nul 2>nul & Node", "$file"] Change into"cmd": ["Node", "$file"] Try it first.
Http://www.cnblogs.com/52cik/p/sublime-runjs.html