[Reserved] How to install Node.js

The following describes the Mac , Ubuntu , Centos and Windows installation Node.js .

Mac

In Mac, if you like to use homebrew , then only one line can be installed:

brew install node

Otherwise, only considering manual installation, the steps are as follows:

  1. Install Xcode
  2. Install git
  3. Run the following command-line compiler node.js
    1 git clone git://github.com/joyent/node.git
    2 cd node
    3 ./configure
    4 make
    5 sudo make install

Ubuntu

  1. Installation dependencies
    1 sudo apt-get install g++ curl libssl-dev apache2-utils
    2 sudo apt-get install git-core
  2. Run the following command line:
    1 git clone git://github.com/joyent/node.git
    2 cd node
    3 ./configure
    4 make
    5 sudo make install

Windows

Use cygwin to install node, the following steps:

  1. Install cygwin
  2. In cygwin directory, run setup.exe installation package in the following list
    • devel → openssl
    • devel → g++-gcc
    • devel → make
    • python → python
    • devel → git
  3. Run cygwin
  4. Run the following command line:
    1 git clone git://github.com/joyent/node.git
    2 cd node
    3 ./configure
    4 make
    5 sudo make install

Centos

1 yum install gcc-c++ openssl-devel
2 wget --no-check-certificate https://github.com/joyent/node/tarball/v0.3.3
3 tar -xzvf ry-node-v0.3.3-0-g57544ba.tar.gz
4 cd ry-node-v0.3.3-0-g57544bac1
5 ./configure
6 make
7 make install

Hello Node.js!

For example hello_node.js write a small program to verify the installation:

1 var http =require('http');
2 http.createServer(function(req, res){
3 res.writeHead(200,{'Content-Type':'text/plain'});
4 res.end('Hello Node.js\n');}).listen(8124,"127.0.0.1");
5 console.log('Server running at http://127.0.0.1:8124/');

A node to run this code

1 node hello_node.js
2 Server running at http://127.0.0.1:8124/

Now, open http://127.0.0.1:8124/ browser, you should see a good news.

Reproduced in: https: //my.oschina.net/weisenz/blog/200649

Guess you like

Origin blog.csdn.net/weixin_33877092/article/details/91920873