CentOS安裝NodeJS及Express開發架構,centosnodejs

來源:互聯網
上載者:User

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吧……說實話……除了這倆我還真不知道用啥。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.