Linux(Debian)下Nodejs安裝方法

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   使用   ar   strong   檔案   

Linux(Debian)下Nodejs安裝方法

 

一:安裝node.js

1、在官方網站下載 http://www.nodejs.org/download/ 

 

下載後,在/home/hongwei有一個檔案node-v0.10.32-linux-x86.tar.gz ,將其解壓後,檔案夾為 node-v0.10.32-linux-x86,

2、查看版本

cd node-v0.10.32-linux-x86

ls 

./node -v 

查看版本是 v0.10.32

3、將其建立建立連結

ln -s /home/hongwei/node-v0.10.32-linux-x86/bin/node /usr/local/bin/node

ln -s /home/hongwei/node-v0.10.32-linux-x86/bin/npm /usr/local/bin/npm

這樣就安裝好了,在終端輸入 node 就可以查看相關資訊了

說明:強烈不建議使用 apt-get 進行安裝,因為安裝後,不顯示相關資訊。

sudo apt-get install nodejs

sudo apt-get install npm

 

二:安裝 Express

1、Express的官方網址是 http://expressjs.com/ ,但官方的 git 地址是 https://github.com/strongloop/express.git ,先將其git下來 

git clone https://github.com/strongloop/express.git

於是本地就有 express 目錄。

2、安裝 express 時,一定要按照 git 上的方法進行安裝,不要根據相關提示進行安裝,否則版本是不會的。官方是這樣安裝的

 

$ npm install express

$ npm install -g [email protected]

$ express /tmp/foo && cd /tmp/foo

$ npm install

$ npm start

 

這樣我們再查看一下版本 express -V (這是大寫V啊) 於是看到版本是 4.9.0

 

3、建立網站基本結構

$ express -t ejs microblog

$ cd microblog && npm install

過幾秒鐘後,再運行

$ DEBUG=microblog ./bin/www

 

這樣就可以看到我們的 express 的基本網站了,

 


Linux(Debian)下Nodejs安裝方法

聯繫我們

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