Home  >  Article  >  Web Front-end  >  How to install Node.js_javascript tips on Mac/Windows

How to install Node.js_javascript tips on Mac/Windows

WBOY
WBOYOriginal
2016-05-16 17:12:451379browse
Mac

Under Mac, if you like to use homebrew, you can install it with just one line:

brew install node

Otherwise, just You can consider manual installation. The steps are as follows:
Install Xcode
Install git
Run the following command line to compile node.js
Copy code 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:
Copy the code The code is as follows:

git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

Windows

Use cygwin to install node. The steps are as follows:
Install cygwin
In the cygwin directory, run setup.exe to install the packages in the list below
devel → openssl
devel → g -gcc
devel → make
python → python
devel → git
run cygwin
Run the following command line:
Copy code The code is as follows:

git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

Centos
copy Code 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:
Copy code 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
Copy the 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/ with a browser, you should be able to see a good message.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn