Nodejs的Express完成安裝指導

來源:互聯網
上載者:User

標籤:public   express   ack   tps   htm   tracking   jad   views   版本   

一、安裝

官網http://expressjs.com/

express4.X的有一些變化,4.x版本中將命令工具單獨分出來了(https://github.com/expressjs/generator),所有要先按裝express-generator,否則建立項目時,會提示express命令沒找到

[plain] view plain copy  
  1. $ npm install -g express-generator #需先安裝express-generator  
  2.   
  3. $ npm install -g express  
  4.   
  5. $ express -V  #驗證是否安裝成功  

 

二、建立項目

[plain] view plain copy  
  1. $ express myfirstexpress # express的預設模版採用jade,若需要ejs模版支援,加上-e選項,即 express -e myfirstexpress  
  2. $ cd myfirstexpress  
  3.   
  4. $ ls  
  5. app.js  bin  package.json  public  routes  views #項目的目錄結構   

 

三、運行項目

[plain] view plain copy  
  1. $ npm install #需要等待一段時間,因為需要擷取很多的庫檔案  
  2.   
  3. $ npm start  
  4.   
  5. > [email protected] start /root/myfirstexpress  
  6. > node ./bin/www  

 

四、訪問第一個express項目

瀏覽器中輸入 http://你的IP:3000

顯示

[html] view plain copy  
  1. Express  
  2.   
  3. Welcome to Express  

說明express安裝成功

Nodejs的Express完成安裝指導

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.