Mac/Windows下如何安裝Node.js
更新時(shí)間:2013年11月22日 16:59:30 作者:
在Mac、Ubuntu、Windows、Centos下如何安裝Node.js,想必有一些朋友還不會吧,本文整理了一些,需要的朋友可以參考下
Mac
在Mac下,如果你喜歡用homebrew,那么只用一行就可以裝好:
brew install node
否則,只能考慮手工安裝了,步驟如下:
安裝Xcode
安裝git
運(yùn)行下面的命令行編譯node.js
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Ubuntu
安裝依賴包
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
運(yùn)行下面的命令行:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Windows
用cygwin來安裝node,步驟如下:
安裝cygwin
在cygwin的目錄下,運(yùn)行setup.exe安裝下面列表中的包
devel → openssl
devel → g++-gcc
devel → make
python → python
devel → git
運(yùn)行cygwin
運(yùn)行下面的命令行:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Centos
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!
寫一段小程序例如hello_node.js來驗(yàn)證安裝是否正確:
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/\');
用node來運(yùn)行這段代碼
node hello_node.js
Server running at http://127.0.0.1:8124/
現(xiàn)在,用瀏覽器打開 http://127.0.0.1:8124/ , 應(yīng)該能夠看到一條好消息。
在Mac下,如果你喜歡用homebrew,那么只用一行就可以裝好:
brew install node
否則,只能考慮手工安裝了,步驟如下:
安裝Xcode
安裝git
運(yùn)行下面的命令行編譯node.js
復(fù)制代碼 代碼如下:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Ubuntu
安裝依賴包
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
運(yùn)行下面的命令行:
復(fù)制代碼 代碼如下:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Windows
用cygwin來安裝node,步驟如下:
安裝cygwin
在cygwin的目錄下,運(yùn)行setup.exe安裝下面列表中的包
devel → openssl
devel → g++-gcc
devel → make
python → python
devel → git
運(yùn)行cygwin
運(yùn)行下面的命令行:
復(fù)制代碼 代碼如下:
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install
Centos
復(fù)制代碼 代碼如下:
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!
寫一段小程序例如hello_node.js來驗(yàn)證安裝是否正確:
復(fù)制代碼 代碼如下:
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/\');
用node來運(yùn)行這段代碼
復(fù)制代碼 代碼如下:
node hello_node.js
Server running at http://127.0.0.1:8124/
現(xiàn)在,用瀏覽器打開 http://127.0.0.1:8124/ , 應(yīng)該能夠看到一條好消息。
相關(guān)文章
詳解js中構(gòu)造流程圖的核心技術(shù)JsPlumb(2)
這篇文章主要介紹了js中構(gòu)造流程圖的核心技術(shù)JsPlumb,jsPlumb是一個(gè)強(qiáng)大的JavaScript連線庫,它可以將html中的元素用箭頭、曲線、直線等連接起來,適用于開發(fā)Web上的圖表、建模工具等,需要的朋友可以參考下2015-12-12如何利用moment處理時(shí)間戳并計(jì)算時(shí)間的差值
前端很多場景都會涉及到對時(shí)間的處理,我所用得最多的庫是moment,下面這篇文章主要給大家介紹了關(guān)于如何利用moment處理時(shí)間戳并計(jì)算時(shí)間的差值的相關(guān)資料,需要的朋友可以參考下2022-04-04如何在JavaScript中優(yōu)雅的提取循環(huán)內(nèi)數(shù)據(jù)詳解
這篇文章主要給大家介紹了關(guān)于如何在JavaScript中優(yōu)雅的提取循環(huán)內(nèi)數(shù)據(jù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03javascript動態(tài)向網(wǎng)頁中添加表格實(shí)現(xiàn)代碼
動態(tài)向網(wǎng)頁中添加表格的方法有很多,本文為大家介紹下利用javascript是如何實(shí)現(xiàn)的2014-02-02javaScript 動態(tài)訪問JSon元素示例代碼
訪問JSon元素的方法有很多,在搜的時(shí)候會找到很多,本文使用javascript來動態(tài)訪問json元素,感興趣的朋友可以練練手哦2013-08-08JavaScript原型式繼承實(shí)現(xiàn)方法
這篇文章主要介紹了JavaScript原型式繼承實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11