First step: Install Sublime Text3 first. Detailed tutorials can be self-Baidu, this side is not specifically introduced.
The second step, the installation of Nodejs plug-ins, there are two ways
The first way: Download the Https://github.com/tanepiper/SublimeText-Nodejs compressed package directly, and then rename it to Nodejs in the packages directory after compression. Package Open Mode:preferences-> Browser Package
Second way: Download through the package control and install package
Step three: Install Nodejs. There's not much to say here.
After the above three steps are completed, it is not possible to compile the Nodejs directly in sublime text. The following settings are also required:
1, modify the compilation options, in the Nodejs directory under the package directory, open the Nodejs.sublime-build file, the original content is as follows
{ "cmd": ["Node", "$file"], "File_regex": "^[]*file \" (... *) \ ", line ([0-9]*)", "selector": "Source.js", "Shell":true, " Encoding ":" cp1252 ", " Windows ": { " cmd ": [" taskkill/f/im Node.exe & Node ", "$file"] }, "Linux": { "cmd": ["Killall node; Node "," $file "] }}
There are two places that need to be modified
the first place to change is: encoding. you need to set encoding to gb2131 or utf-8. This way, the compiled output will not appear garbled.
The second place to modify is: cmd command. Such a configuration can be used directly under Windows.
"cmd": ["Node", "$file"]
However, this configuration has a fatal disadvantage, that is, each time the build, will restart a node.exe process, and will occupy a port. In the above Windows CMD configuration, it was intended to kill all node.exe processes before starting node.exe and then start Node.exe. However, this command does not write, the direct use of the compilation will be unsuccessful. Therefore, the CMD needs to be modified.
"Windows": { "cmd": ["Taskkill", "/F", "/im", "Node.exe", "&", "Node", "$file"] },
The complete Nodejs.sublime-build code after the modification is as follows:
{ "cmd": ["Node", "$file"], "File_regex": "^[]*file \" (... *) \ ", line ([0-9]*)", "selector": "Source.js", "Shell":true, " Encoding ":" Utf-8 ", " Windows ": { " cmd ": [" Taskkill ","/F ","/im "," Node.exe "," & "," Node "," $file "] }, " Linux ": { " cmd ": [" Killall node; Node "," $file "] }, " OSX ": { " cmd ": [" Killall node; Node $file "] }}
After the setup is complete, remember to restart sublime text.
Finally, by giving a small example to verify the results.
App.js
var http = require (' http '); Http.createserver (function(req, res) { // body ... Res.writehead (' $ ', {' Content-type ': ' Text/plain '}); Res.end (' Hello world \ n ');}). Listen (8124, ' 127.0.0.1 '); Console.log (' Server running at ');
Compile file: Direct ctrl+b or click Tools--build to compile the file.
At this time in sublime text off the window can also see Console.log information
At this time, open the browser, enter the 127.0.0.1:8124 can be seen in the browser output effect.
At this point, Windows based on the sublime Text3 Nodejs environment is built. You can start writing code.
Sublime Text3-based NODEJS environment built under Windows