CentOS安裝NodeJS及Express開發架構,centosnodejs
本文示範在Linux上安裝NodeJS及Express開發架構註:本人在http://www.nodejs.org/官網上下載了nodejs最新版本NodeJS v0.10.29 但是在./configure的時候,說沒有找到路徑,無奈之下,只好將nodejs版本降低到v0.10.24。現在講運行步驟記下,以免將來忘掉,
安裝過程如下:Step 1、確認伺服器有nodejs編譯及依賴相關軟體,如果沒有可通過運行以下命令安裝。
[root@BobServerStation local]# yum -y install gcc gcc-c++ openssl-devel
Step 2、下載NodeJS源碼包並解壓。
[root@BobServerStation local]# wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz[root@BobServerStation local]# tar zxvf node-v0.10.24.tar.gz[root@BobServerStation local]# cd node-v0.10.24
Step 3、配置、編譯、安裝。
[root@BobServerStation node-v0.10.24]# ./configure --prefix=/usr/local/node[root@BobServerStation node-v0.10.24]# make && make install
Step 4、接下來配置Node環境
[root@BobServerStation node-v0.10.24]# vim /etc/profile
#set nodejs envexport NODE_HOME=/usr/local/nodeexport PATH=$NODE_HOME/bin:$PATHexport NODE_PATH=$NODE_HOME/lib/node_modules:$PATH[root@BobServerStation node-v0.10.24]# source /etc/profile
--重啟生效Step 5、測試是否安裝成功
[root@BobServerStation node-v0.10.24]# node -vv0.10.24
出現NodeJS版本號碼則表示OK。Step 6、NodeJS之Hello World
[root@BobServerStation node-v0.10.24]# node> console.log(”Hello NodeJS, I'm Bob.Z“);Hello NodeJS, I'm Bob.Zundefined>
輸出:Hello NodeJS, I'm Bob.ZStep 7、安裝Express開發架構
[root@BobServerStation local]# npm install express -g
Step 8、建立Demo項目
[root@BobServerStation local]# express DemoApp[root@BobServerStation local]# cd DemoApp[root@BobServerStation DemoApp]#
Step 9、進入項目目錄並安裝項目相依元件
[root@BobServerStation local]# cd DemoApp[root@BobServerStation DemoApp]# npm install
Step 10、相依元件安裝完成後啟動app
[root@BobServerStation DemoApp]# node appExpress server listening on port 3000
最後通過瀏覽器訪問伺服器3000連接埠,頁面顯示,Express
Welcome to Express
Node + Express成功運行,順利開啟Node開發之旅,enjoy it!
對於NODEJS EXPRESS架構安裝的問題
如果執行命令列的express,需要做如下操作:
npm install -g express-generator@3官方github上是這麼說的。
問在ubuntu環境下開發nodejs,並且使用express架構,應該用什的javascript ide工具?麻煩大家給推介
vim或Eclipse吧……說實話……除了這倆我還真不知道用啥。