How to install Node. js_javascript on Mac or Windows

Source: Internet
Author: User
Tags install node
If you want to install Node. js on Mac, Ubuntu, Windows, and Centos, you may not have any friends. I have sorted out some articles. If you need them, refer to them. Mac

On Mac, if you like to use homebrew, you can use only one line to install it:

Brew install node

Otherwise, you can only manually install it as follows:
Install Xcode
Install git
Run the following command line to compile node. js

The Code is as follows:


Git clone git: // github.com/ry/node.git
Cd node
./Configure
Make
Sudo make install


Ubuntu
Install dependency packages

Sudo apt-get install g ++ curl libssl-dev apache2-utils
Sudo apt-get install git-core

Run the following command line:

The Code is as follows:


Git clone git: // github.com/ry/node.git
Cd node
./Configure
Make
Sudo make install


Windows

To install node with cygwin, follow these steps:
Install cygwin
Run setup.exe in the cygwindirectory to install the package in the following list.
Devel → openssl
Devel → g ++-gcc
Devel → make
Python → python
Devel → git
Run cygwin
Run the following command line:

The Code is as follows:


Git clone git: // github.com/ry/node.git
Cd node
./Configure
Make
Sudo make install


Centos

The Code is as follows:


Yum install gcc-c ++ openssl-devel
Wget -- no-check-certificate https://github.com/ry/node/tarball/v0.3.3
Tar-xzvf ry-node-v0.3.3-0-g57544ba.tar.gz
Cd ry-node-v0.3.3-0-g57544bac1
./Configure
Make
Make install


Hello Node. js!

Write a small program such as hello_node.js to verify whether the installation is correct:

The Code is as follows:


Var http = require (\ 'HTTP \');
Http. createServer (function (req, res ){
Res. writeHead (200, {\ 'content-Type \ ': \ 'text/plain \'});
Res. end (\ 'Hello Node. jsn \');
}). Listen (8124, "127.0.0.1 ");
Console. log (\ 'server running at http: // 127.0.0.1: 8124 /\');


Use node to run this code

The Code is as follows:


Node hello_node.js
Server running at http: // 127.0.0.1: 8124/


Now, open http: // 127.0.0.1: 8124/in a browser, and you should be able to see good news.

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.