Today, just have a demand, that is, I want to use JS to write algorithms or their own learning JS functions and other knowledge, hope that the program can be written directly debugging, and not every time to use the browser to resolve, so specifically to search the data, and then refer to a number of articles after the final configuration success, so is to share experience ~ ~
I. Installation of Node.js
Of course, you can use other environment such as JSC to run JS, this article uses the Nodejs. First make sure your computer is Nodejs and added to the environment variable.
Download Address: https://nodejs.org/en/
Second, add this build System for sublime text
Just open Sublime Text and select Tools > Build System > New build System.
As shown in the figure:
Paste the content and save it.
{
"cmd": ["Node", "--use-strict", "--harmony", "$file"],
"selector": "Source.js"
}
In the above build file (Node.sublime-build), Node is executing the command,--harmony and--use-strict are execution parameters, $file is the current file name, So a build operation is actually equivalent to executing node--use-strict--harmony filename on the command line. --harmony indicates that ES Harmony features are enabled, and these features are currently only run in strict mode, so you need to add use-strict parameters at the same time.
Third, the test is installed successfully
1. Select the "Node" you just created in the Tools > Build System, and then create a new Test.js file.
My test code is as follows:
var a = 1;
var b = 2;
Console.log (A+B);
Using the shortcut key CTRL + B, you get the following execution results:
The above steps can be completed, and you can directly use sublime text for debugging.