1, first install sublime Text 2 or 3 can be
2. Download the sublime Text Nodejs plugin to get the ZIP package (which will be described in the following article)
3, the download after the decompression directly renamed to Nodejs (must be the name, otherwise sub2 edit the default file will be error) put to preferences--> browseBrowse Packagesthe folder where the package is located.
4. Open the Nodejs folder to find the root directory inside the Nodejs.sublime-build file 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"]
}
}
Change cp1252 to gb2312 unless you are an English system, otherwise garbled
If it is sublime Text 3 will:
Otherwise the report can not find the path error, if it is 2, do not change otherwise every building a node process.
Restart the program!!
5. Configure the Nodejs path Preferences-->package Setting-->nodejs-->default as follows:
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "C:\\Program Files\\nodejs\\node.exe",
// Same for NPM command
"npm_command": "C:\\Program Files\\nodejs\\npm.cmd",
// as ‘NODE_PATH‘ environment variable for node runtime
"node_path": true,
"expert_mode": false,
"ouput_to_new_tab": false
}
The tool in the run is not related to gray, each press Ctr+b compile, the following will be in time to output results.
For the difference between 2 and 3:
1. If the node. JS plugin is installed with the package control, SUB2 will be installed in:
C:\Users\Administrator\AppData\Roaming\Sublime the Text 2\packages\ directory.
And SUB3 will be installed in:
C:\Program files\sublime Text 3\data\installed Packages directory and will not be decompressed, each time the SUB3 is launched in the cache (in order to green), At this time, edit the Nodejs.sublime-build file to use the zip to open the edit and save the restart software.
2. If you install the node. JS plugin with the package control, you will find that you cannot edit path Preferences-->package Setting-->nodejs-->default, this time edit path Preferences-->package Setting-->nodejs-->user He will overwrite the default, in fact this is the official recommended practice.