First install sublime Text3, Baidu a bunch, find it yourself. Theoretically sublime text2 should also be possible. I can only say: This software is really too tough.
Cross-platform, rich plug-in system, plus plug-ins is basically a powerful IDE. I am currently using Emmet, Python, and some formatted plugins (Xml,json), plus this installation of node. js.
Sublimetext-nodejs plug-in (Https://github.com/tanepiper/SublimeText-Nodejs)
Originally in the sublime text plug-in library has Nodejs plug-in, but after trying to install, found unable to modify the compilation settings, did not find nodejs.sublime-build files, and later on GitHub saw the next person's installation instructions and then re-install.
There are two different ways to install:
1, download the compressed package directly and extract to the sublime text in the packages directory. See where the package directory can be viewed through the preferences--> in the menu barBrowse Packages directly opens the package directory.
2. Use the GIT command to download to the package directory (GIT clone https://github.com/tanepiper/sublimetext-nodejs "D: \ programfiles \ sublimetext 3 \ data \ packages \ nodejs")
Modify the compilation options. In the nodejs directory under the package directory, open nodejs.sublime-build. 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 2 places need to be modified, one is code, in order to avoid garbled code, need to change to cp936; the other is the cmd command, itself if just want to run the NODEJS program simply, Windows CMD can directly"cmd": ["node", "$file"],But this is not conducive to the development environment, because in this way, each build will restart a node.exe process, and occupy a port, which is certainly not what we want. The above CMD was originally intended to kill the node.exe process before starting node.exe, and then start node.exe. However, this command is not written correctly. If it is used directly, the compilation is not successful. Simple processing is needed for the CMD command. The contents of the modified nodejs.sublime-build file are as follows:
{
"cmd": ["Node""$file"],
"File_regex" "^[]*file \" (...) \ ", line ([0-9]*)",
"selector" "Source.js",
"Shell":true,
"Encoding" "cp936",
"Windows":
{
"cmd": ["Taskkill","/F""/im""node.exe","&", "Node" "$file"]
},
"Linux":
{
"cmd": ["Killall node; Node "$file"]
}
}
After restarting sublime text, the configuration is complete. Let's write a short piece of code to verify that it works.
var http = require (' http ');
var os = require (' OS ');
Http.createserver (function (request, Response) {
Response.writehead ($, {' content-type 'text/plain'});
Response.End (' Hello world\n ');
}). Listen (3000);
Console.log (' Server running at Http://127.0.0.1:3000/');
ctrl+bAfter compiling this code, the Sublime text window will display
Server running at Http://127.0.0.1:3000/
If a previously running node process is in progress, the node process will be killed first, and then node can be started, as shown below:
Success: The process "Node.exe" has been terminated with a PID of 154588.
Server running at Http://127.0.0.1:3000/
In this case, the server is started successfully, open the browser, enter Http://127.0.0.1:3000/, the page shows Hello World is normal interaction.
Windows Sublime text node. JS Development Environment Build