Introduction, installation and configuration of Node. js study notes _ node. js

Source: Internet
Author: User
Tags install node
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.

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.