This article mainly introduces introduction to Node. js and the installation and development environment. If you need it, refer to the following learning materials.
1. go deep into Node. js
2. Node. js Development Guide
Introduction (only what I think is important)
Node. js is a platform that disconnects Javascript from the browser and runs on the server. It is not a language;
Node. js uses the Javascript engine V8 from Google Chrome. You don't have to worry about the headache of Javascript compatibility when running on a browser.
A single thread, asynchronous IO, and event-driven design is used to achieve high concurrency (asynchronous events also increase the difficulty of Development and debugging to a certain extent );
Creating an HTTP server in Node. js is good news for website development;
Home: http://nodejs.org/
Http://nodejs.org/api/ (latest) APIs)
Http://nodeapi.ucdok.com/#/api/ APIs
Install Node. Js
Operating System Environment: WiN 7 64-bit
Installation in Windows is relatively simple
Http://nodejs.org/download/
Download the corresponding operating system installation file (install the latest version)
Follow the prompts to go to the next step until the installation is successful. You can see (C: \ Program Files \ nodejs) in the default installation path. The default path can be modified during installation.
After the installation is successful, enter "node-v" in the "command prompt" to view the installation version. The installation is successful if the version is output.
NPM Introduction
Windows Node. the js installation package contains the Node Pageaged Modules https://npmjs.org/(npm), the node. js itself has basic modules. With this npm, you can install a variety of nodes. js library to meet the actual development requirements.
Common commands:
View help
Npm help or npm h
Installation Module
Npm intstall
Install the module in the global environment (-g: enable global mode)
Npm install-g
More: https://npmjs.org/doc/install.html
Uninstall Module
Npm uninstall
Display the modules installed in the current directory
Npm list
After the installation is successful, the npm and node. js paths are added to the PATH user environment variables and system environment respectively.
Development Tools
WebStorm I downloaded a 7.0 file. It seems that many of them are used.
WebStorm: http://www.jetbrains.com/webstorm/
Do. for NET development, you can select WebMatrix3. Download and install it directly. The operation is very convenient and you can directly create a Nodejs project after a while without much explanation. If it is only developed in a Windows environment, we recommend that you use it.
WebMatrix: http://www.microsoft.com/web/webmatrix/
I finally chose Sublime. I can maintain a uniform development tool on each platform. There are many configuration methods on the Internet.
Sublime: http://www.sublimetext.com/(the software does not need to be registered, the use of the process from time to time will pop up the need to register the window, you can cancel)
Sublime Node. js Development Environment Configuration
Download and install the Node. js installation package and then start configuring
1. Install Sublime Text 2 first
2. Run Sublime and choose Tools> Build System> new Build System from the menu.
3. Copy
The Code is as follows:
{
"Cmd": ["node", "$ file"],
"File_regex": "^ [] * File \"(...*?) \ ", Line ([0-9] *)",
"Selector": "source. javascript"
}
4. Save the file as NodeJs. sublime-build.
5. Choose Tools> Build System> NodeJs from the menu.
6. install Package Control. Run Sublime and press the shortcut key Ctrl + '. Enter the following in the console and press Enter;
The Code is as follows:
Import urllib2, OS, hashlib; h = '7183a2d3e96f11eeadd761d777e62404 '+ 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'package Control. sublime-package '; ipp = sublime. installed_packages_path (); OS. makedirs (ipp) if not OS. path. exists (ipp) else None; urllib2.install _ opener (urllib2.build _ opener (urllib2.ProxyHandler (); by = urllib2.urlopen ('HTTP: // sublime.wbond.net/'+ pf. replace ('', '% 20 ')). read (); dh = Hashlib. sha256 (). hexdigest (); open (OS. path. join (ipp, pf), 'wb '). write (by) if dh = h else None; print ('error validating download (got % s instead of % s), please try manual install '% (dh, h) if dh! = H else 'Please restart Sublime Text to finish installation ')
See http://www.dbpoo.com/sublime-text2-theme-sod/ for details
7. After the installation is complete, restart Sublime and press the shortcut key Ctrl + Shift + P. Enter install, select Install Package, and press Enter.
8. Enter nodejs and select Nodejs for installation (JavaScript & NodeJs Snippets can be installed)
9. Create the test. js file and enter console. log ('Hello Node. js'). Press the shortcut key Ctrl + B to run the file! For example
Configure the Sublime Node. js development environment!
If you want a better theme color scheme, see: http://www.infoq.com/cn/minibooks/nodejs
Extension: Install multi-version Manager
Install the multi-version manager nvmw (NVM used in the Node Development Guide, which does not seem to work on Windows. I found this in www.npmjs.org. Although I can't learn it, install it first)
Installation command
Npm install-g nvmw
Because it is not used, we will not do much about it. For details, refer
Https://npmjs.org/package/nvmw