This is the first article in the Node. js Study Notes series. It mainly explains how to install Node. js on Windows and Linux. The software installation version 0.12.0 is used as an example. I hope you will like it. Simply put, Node. js is the JavaScript running on the server.
Node. js is a platform based on Chrome JavaScript runtime.
Node. js is an event-driven I/O server-side JavaScript environment. Based on Google's V8 engine, the V8 engine executes Javascript very quickly and performs very well.
Who is suitable for reading this tutorial?
If you are a front-end programmer who does not understand dynamic programming languages such as PHP, Python, or Java and want to create your own services, Node. js is a very good choice.
Node. js is the JavaScript running on the server. If you are familiar with Javascript, you will easily learn Node. js.
Of course, if you are a backend programmer and want to deploy some high-performance services, learning Node. js is also a good choice.
Before learning this tutorial, you need to understand
Before continuing this tutorial, you should understand some basic computer programming terms. If you have learned Javascript, PHP, Java and other programming languages, it will help you learn Node. js programming more quickly.
Install and configure Node. js
Here, I will demonstrate how to install Node. js on Windows and Linux. The software installation version 0.12.0 is used as an example.
Node. js installation package and source code: http://nodejs.org/download/
Depending on different platforms, You need to select the required Node. js installation package.
Note: To install Node. js on Linux, Python 2.6 or 2.7 is required. We do not recommend that you install Python 3.0 or later.
Install Node. js on Windows
Windows Installation Package (. msi ):
Download from the official website provided above.
Demo environment:
Operating System: Windows 8.1 Enterprise x64
Node. js version: 0.12.0
Installation steps:
Step 1: double-click the downloaded installation package node-v0.12.0-x64.msi to display the welcome page, as shown below:
Step 2: Click Next to display the Node. js license page:
Step 3: Check "I accept the terms in the License Agreement" to agree to the License Agreement and click Next. the following page is displayed:
Step 4: Node. the default installation path of js is "C: \ Program Files \ nodejs \". You can modify it. Here I changed it to drive D and click Next. The installation mode and module selection page appears:
Step 5: Click Next by default. You are ready for installation:
Step 6: Click Install to start installation:
Step 7: After half a minute, the installation is complete. Click Finish:
Step 8: Configure environment variables:
After the node. js installation is complete, the directory path of node.exe is automatically configured in the pathenvironment variable of the system. However, after the installation is complete, enter node in the doscommand to display an error.
Open the system environment variable and find that it has been configured, but running "set path" in dos does not see the node. js configuration, which is a matter of character .. Restart the computer and reload it.
You can also delete the automatic configuration and add it manually. As follows:
Open Computer properties-advanced-environment variables and find the path variable in the system Variable list:
Click "edit" and add the nodejs installation directory at the end:
Step 9: Check whether the installation is successful:
Click Start-run-cmd, open dos, and enter "node -- version" to check the Node. js version:
If it is displayed normally, OK. installation is complete!
Install Node. js on Linux
Ubuntu source code Installation
The following section describes how to install Node. js in Ubuntu Linux. For other Linux systems, such as Centos, follow these steps.
Get the Node. js source code on Github, or download it from the official website:
After the download is complete, change the source package name to 'node '.
Modify directory permissions:
Use './configure' to create a compilation file.
Compile: make.
Complete the installation: make install.
Finally, run the 'node -- version' command to check whether node. js is successfully installed.
Ubuntu apt-get command Installation
The command format is as follows:
The Code is as follows:
Sudo apt-get install nodejs
Sudo apt-get install npm
Install nodejs in centOS
1. Download source codeYou need to download the latest nodejsrepository at http://nodejs.org/. this document uses v0.12.0as an example:
The Code is as follows:
Cd/usr/local/src/
Wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz
2. decompress the source code:
The Code is as follows:
Tar zxvf node-v0.12.0.tar.gz
3. Compile and install:
The Code is as follows:
Cd node-v0.12.0
./Configure -- prefix =/usr/local/node/0.12.0
Make
Make install
4. Configure NODE_HOME and enter the profile to edit the environment variable:
The Code is as follows:
Vim/etc/profile
Set the nodejs environment variable inExport PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROLAdd the following content to a row:
The Code is as follows:
# Set for nodejs
Export NODE_HOME =/usr/local/node/0.12.0
Export PATH = $ NODE_HOME/bin: $ PATH
: Wq save and exit. Compile/etc/profile to make the configuration take effect.
The Code is as follows:
1 source/etc/profile
Verify whether the configuration is successfully installed
The Code is as follows:
Node-v
The output v0.12.0 indicates that the configuration is successful.
Npm module installation path
The Code is as follows:
/Usr/local/node/0.12.0/lib/node_modules/
The above is all about introduction, installation, and configuration of node. js in this article. We will continue to update this series in the future, hoping to help you.