Under Windows configuration Sublime Text 2 development Nodejs

Source: Internet
Author: User
Tags sublime text


How to install the sublime Text 2 plugin: 1. Direct installation


Installing the sublime Text 2 plugin is convenient and can be downloaded directly from the installation package to the Packages directory (menu->preferences->packages).


2. Installing using the Package control component


You can also install the package control component and install it directly online:


1. Press Ctrl+` to bring up the console
2. Paste the following code into the bottom command line and press Enter:
Import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join (ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
3. Restart Sublime Text 2.
4. If you see the package control item in the Perferences->package settings, the installation is successful.


If this method cannot be successfully installed, you can download the file here manually.



To install a plugin using the package control method:


    1. Press Ctrl+shift+p to bring up the command panel
    2. Enter install to bring up the Install Package option and enter, then select the plug-in you want to install in the list.


The uncomfortable is that some network environment may not allow access to unfamiliar network environment to set up a firewall, and sublime Text 2 seemingly unable to set up the proxy, may not get the list of installation packages.
Ok, the method is finished, here is the topic, some useful sublime Text 2 plugin:



Method One: Take advantage of the first installation method (direct installation)



1 Download Sublime Text 2
http://www.sublimetext.com/



2 download Nodejs plugin, download Zip package
Https://github.com/tanepiper/SublimeText-Nodejs



3 Unzip the zip and rename it to Nodejs



4 Copy the Nodejs to the C:\Users\Administrator\AppData\Roaming\Sublime Text 2\packages directory



5 Restart Sublime Text 2->tools-->build System-->nodejs



6 Configure the Nodejs path Preferences-->package setting-->nodejs-->default, with my configuration as follows



{
Save before running commands
"Save_first": true,
If present, use the This command instead of plain "node"
e.g. "/usr/bin/node" or "C:\bin\node.exe"
"Node_command": "D:\\tools\\nodejs\\node.exe",
Same for NPM command
"Npm_command": "D:\\tools\\nodejs\\npm.cmd",






}



7 C:\Users\Administrator\AppData\Roaming\Sublime Text 2\packages\nodejs\nodejs.sublime-build to be modified, with my revised content as follows:



"File_regex": "^[]*file \" (...) \ ", line ([0-9]*)",
"Selector": "Source.js",
"Shell": true,
"Encoding": "GB2312",
"Windows":
{
"cmd": ["D:\\tools\\nodejs\\node.exe", "$file"]
},
"Linux":
{
"cmd": ["Killall node; Node "," $file "]
}
}


8 All right, the development tools are ready to be developed.


We create a JS file in the editor, Ctrl+b Run or run on Tools->nodejs.






Method Two: Install using the Package control component



1. Install Sublime Text 2 first



2. Run sublime, find tools---> Build system---> New build system on the menu



3. Copy the file into the




 
 
{
    "cmd": ["node", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.javascript"
}


4. Save the file as Nodejs.sublime-build



5. On the menu, locate tools---> Build System---> select NodeJs



6. Install the package control, run the sublime, press the shortcut key ctrl + '; Enter the following in the console and return;




 
import urllib2,os;pf=‘Package Control.sublime-package‘;ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),‘wb‘).write(urllib2.urlopen(‘http://sublime.wbond.net/‘+pf.replace(‘ ‘,‘%20‘)).read())


7. After the installation is complete, restart the sublime, press the shortcut key CTRL + Shift + P; Enter install, select Install package and enter






8. Enter NodeJs and select NodeJs installation (can be loaded with JavaScript & NodeJs Snippets)






9. Create a new Test.js file and enter Console.log (' Hello node. js '); Press the shortcut key CTRL + B to run, successfully output! Such as









Configuring the Sublime node. JS development environment Here is a success!



If you want a better look at the theme color scheme please refer to: Http://www.infoq.com/cn/minibooks/nodejs



  
Extension: Installing multi-version Manager



Install the multi-version manager NVMW (Node Development guide in the book used in the Nvm,windows as if not, in the www.npmjs.org to find this, although the study can not use, first put it on again)



Installation commands



NPM install-g NVMW



Because there is no use to it, all do not do a long introduction, Detailed View



Https://npmjs.org/package/nvmw



Under Windows configuration Sublime Text 2 development Nodejs


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.