node. JS is a platform built on the chrome JavaScript runtime and is small and easy to build. Run the port can run in the browser, display the effect, but every time with the browser is also very troublesome, we are talking about in sublime Text2 configuration, is JS in Sublimetext2 run, no longer switch to the browser.
1. First install node. js, directly to the official website to download, and then install, click on the next step, if you need to change the installation path, choose a good installation path. After installation, run NODE-V if the version number is displayed, the installation is successful.
2. At this time, we still can not run the JS file, the first to build a system environment in the sublime Text2: Open Sublime Text--Tools---build-build system--New build S Ystem. Empty the new system and enter
{
"cmd": ["Node", "$file"],
"File_regex": "^[]*file \" (...) \ ", line ([0-9]*)",
"Working_dir": "${project_path:${folder}}",
"Selector": "Source.js",
"Shell": true,
"Encoding": "Utf-8",
"Windows": {
"cmd": ["Node", "$file"]
},
"Linux": {
"cmd": ["Killall node; Node "," $file "]
}
}
Save and name the Node.sublime-build.
3. At this time in sublime Text2 first CTRL + N create a new file and save as JS format, such as: Hello.js. Open the Hello.js file that we just created. Ctrl+b to run, you can see the corresponding output in the console
Sublime Text 3 running the JavaScript console