Node. js getting started

Source: Internet
Author: User
Tags nameserver

What is node. js? Return the server-side JavaScript? I will not explain this concept in this article. I can search for it myself to find out that server-side JS is not a new technology, but a recent node. the popularity of JS broke out. I will explain what node is in a later article. JS. Here is just a pure setup, even the environment is not available, but what server-side JS is playing, everything has become a floating cloud, let's first build an environment, enter a "hello World" page.
Right. If you build Windows 7, you only need to follow me step by step. It's okay. You don't need to know too much details. It's not something we need to care about now, our primary goal now is to set up the environment, otherwise there will be no further steps.
Step 1. Download
Node. JS is to be installed under cygwin in windows. Download The cygwin installer from the cygwin website.

Cygwin is a UNIX simulated environment tool running on Windows.

Cygwin Website: http://cygwin.com/

Direct: http://cygwin.com/setup.exe
Step 2. Install 
To install the cygwin program, you only need to perform the next step.

On the choose a download Source Page, select "Install from Internet ".

On the select your Internet connection page, select> Direct Connect

Select "-" On the choose a download site interface and select the downloaded image. We recommend that you use the Japanese website ending with. JP, which is faster.

Note: If you are installing it for the first time, a warning may pop up, regardless of whether you care about it, click OK.
Step 3. Select the installation component 
Note: because there are many components, we recommend that you search for them. Click the name to select the image. A small square is displayed after the image is selected, and X (Cross) indicates the image is selected.

Devel category 
Gcc-G ++: C ++ Compiler
Gcc-mingw-G ++: mingw32 support headers and libraries for gcc C ++
Gcc4-g ++: G ++ subpackage
Git: fast version control system-core files
Make: the GNU version of The 'make' Utility
OpenSSL-devel: The OpenSSL Development Environment
PKG-config: a utility used to retrieve information about installed Libraries
Zlib-devel: the zlib compression/Decompression Library (Development)

Editor category 
VIM: VI improved-enhanced VI Editor

Python Classification 
All
Note: you only need to click the icon on the Right of python to switch to install.

Web Classification 
Wget: utility to retrieve files from the WWW via HTTP and FTP
Curl: multi-protocol file transfer command-line tool

After the next step, you will be prompted that many dependent components need to be installed. Simply follow the next step.
Note: Since all components are downloaded online, it may take a long time to wait.
Step 4. Run ash.exe

After the installation is complete, an icon will be generated on the desktop (if you select an icon to be generated on the desktop). Do not run this icon!

Open the folder and go to the C: \ cygwin \ bin \ directory. This is the default installation directory. If you have modified the installation directory, go to the bin directory under cygwin's installation directory.

Run ash.exe

Execute the./rebaseall-V command in the pop-up command window.

After the command is executed, execute exit to exit ash.
Step 5. Download and install node. js

Run the cygwin program on the desktop.

Enter the wget http://nodejs.org/dist/node-v0.4.7.tar.gz in the Command window and press Enter.

Note: I am writing this article about node. the latest version of JS is node-v0.4.7, http://nodejs.org/dist/node-v0.4.7.tar.gz is node. JS, you can go to node when reading this article. the JS website can be replaced with the latest download path.

Node. js Website: http://nodejs.org/

Enter the tar xf node-v0.4.7.tar.gz in the Command window, node-v0.4.7.tar.gz for your own version.

Enter the CD node-v0.4.7 in the Command window and press Enter.

Enter./configure in the Command window and press Enter.

Enter make in the Command window and press Enter.

Enter make install in the Command window and press Enter.

OK. Now you have installed node. js.

Enter node -- version in the Command window and press enter to check your node. js version.
Step 6. Set DNS 
Open the folder and go to the C: \ cygwin \ etc \ folder.

Manually create the resolv. conf file.

Use NotePad to open the newly created resolv. conf file and add the following

Nameserver 8.8.8.8
Nameserver 8.8.4.4
Save and close.
Step end. Test whether node. js can be run

Now that you have completed the setup, but you don't know if it can run correctly, let's write an example file to test it.

Create example. js in the C: \ cygwin \ home \ caiyou directory

Caiyou is the user directory

Input
VaR HTTP = require ('http ');

HTTP. createserver (function (request, response ){
Response. writehead (200, {'content-type': 'text/html '});
Response. End ('<B> Hello World </B> ');
}). Listen (8888 );

Console. Log ('server running at http: // 127.0.0.1: 8888 /');

Save (Note: Save As UTF-8 format, otherwise a syntax error will be reported ).

Run cygwin and enter node/example. js in the Command window and press Enter.

Have you seen server running at http: // 127.0.0.1: 8888/

Do not close cygwin. Open your browser and visit http: // 127.0.0.1: 8888/To see if the hello World page is displayed.

Install node. js in Linux

yum install gcc-c++ openssl-devel

1. wget http://nodejs.org/dist/node-v5.0.tar.gz
Tar zxvf node-v0.4.8.tar.gz
CD node-v0.4.8
./Configure -- prefix =/usr/local/node
Make
Make install

@ Hangzhou: greatness is coming out! If the link is invalid, see http://blog.csdn.net/youacai?http://www.cnblogs.com/phphuaibei

What is node. js? Return the server-side JavaScript? I will not explain this concept in this article. I can search for it myself to find out that server-side JS is not a new technology, but a recent node. the popularity of JS broke out. I will explain what node is in a later article. JS. Here is just a pure setup, even the environment is not available, but what server-side JS is playing, everything has become a floating cloud, let's first build an environment, enter a "hello World" page.
Right. If you build Windows 7, you only need to follow me step by step. It's okay. You don't need to know too much details. It's not something we need to care about now, our primary goal now is to set up the environment, otherwise there will be no further steps.
Step 1. Download
Node. JS is to be installed under cygwin in windows. Download The cygwin installer from the cygwin website.

Cygwin is a UNIX simulated environment tool running on Windows.

Cygwin Website: http://cygwin.com/

Direct: http://cygwin.com/setup.exe
Step 2. Install 
To install the cygwin program, you only need to perform the next step.

On the choose a download Source Page, select "Install from Internet ".

On the select your Internet connection page, select> Direct Connect

Select "-" On the choose a download site interface and select the downloaded image. We recommend that you use the Japanese website ending with. JP, which is faster.

Note: If you are installing it for the first time, a warning may pop up, regardless of whether you care about it, click OK.
Step 3. Select the installation component 
Note: because there are many components, we recommend that you search for them. Click the name to select the image. A small square is displayed after the image is selected, and X (Cross) indicates the image is selected.

Devel category 
Gcc-G ++: C ++ Compiler
Gcc-mingw-G ++: mingw32 support headers and libraries for gcc C ++
Gcc4-g ++: G ++ subpackage
Git: fast version control system-core files
Make: the GNU version of The 'make' Utility
OpenSSL-devel: The OpenSSL Development Environment
PKG-config: a utility used to retrieve information about installed Libraries
Zlib-devel: the zlib compression/Decompression Library (Development)

Editor category 
VIM: VI improved-enhanced VI Editor

Python Classification 
All
Note: you only need to click the icon on the Right of python to switch to install.

Web Classification 
Wget: utility to retrieve files from the WWW via HTTP and FTP
Curl: multi-protocol file transfer command-line tool

After the next step, you will be prompted that many dependent components need to be installed. Simply follow the next step.
Note: Since all components are downloaded online, it may take a long time to wait.
Step 4. Run ash.exe

After the installation is complete, an icon will be generated on the desktop (if you select an icon to be generated on the desktop). Do not run this icon!

Open the folder and go to the C: \ cygwin \ bin \ directory. This is the default installation directory. If you have modified the installation directory, go to the bin directory under cygwin's installation directory.

Run ash.exe

Execute the./rebaseall-V command in the pop-up command window.

After the command is executed, execute exit to exit ash.
Step 5. Download and install node. js

Run the cygwin program on the desktop.

Enter the wget http://nodejs.org/dist/node-v0.4.7.tar.gz in the Command window and press Enter.

Note: I am writing this article about node. the latest version of JS is node-v0.4.7, http://nodejs.org/dist/node-v0.4.7.tar.gz is node. JS, you can go to node when reading this article. the JS website can be replaced with the latest download path.

Node. js Website: http://nodejs.org/

Enter the tar xf node-v0.4.7.tar.gz in the Command window, node-v0.4.7.tar.gz for your own version.

Enter the CD node-v0.4.7 in the Command window and press Enter.

Enter./configure in the Command window and press Enter.

Enter make in the Command window and press Enter.

Enter make install in the Command window and press Enter.

OK. Now you have installed node. js.

Enter node -- version in the Command window and press enter to check your node. js version.
Step 6. Set DNS 
Open the folder and go to the C: \ cygwin \ etc \ folder.

Manually create the resolv. conf file.

Use NotePad to open the newly created resolv. conf file and add the following

Nameserver 8.8.8.8
Nameserver 8.8.4.4
Save and close.
Step end. Test whether node. js can be run

Now that you have completed the setup, but you don't know if it can run correctly, let's write an example file to test it.

Create example. js in the C: \ cygwin \ home \ caiyou directory

Caiyou is the user directory

Input
VaR HTTP = require ('http ');

HTTP. createserver (function (request, response ){
Response. writehead (200, {'content-type': 'text/html '});
Response. End ('<B> Hello World </B> ');
}). Listen (8888 );

Console. Log ('server running at http: // 127.0.0.1: 8888 /');

Save (Note: Save As UTF-8 format, otherwise a syntax error will be reported ).

Run cygwin and enter node/example. js in the Command window and press Enter.

Have you seen server running at http: // 127.0.0.1: 8888/

Do not close cygwin. Open your browser and visit http: // 127.0.0.1: 8888/To see if the hello World page is displayed.

Install node. js in Linux

yum install gcc-c++ openssl-devel

1. wget http://nodejs.org/dist/node-v5.0.tar.gz
Tar zxvf node-v0.4.8.tar.gz
CD node-v0.4.8
./Configure -- prefix =/usr/local/node
Make
Make install

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.