ubuntu Nodejs和npm的安裝__js

來源:互聯網
上載者:User

一.NodeJs安裝

1.下載nodejs源碼,這是目前最新版本

http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz

首先確保系統安裝來python,gcc,g++,如果沒有則安裝: 

$ sudo apt-get install python 

$ sudo apt-get install build-essential 

$ sudo apt-get install gcc 

$ sudo apt-get install g++ 

2.解壓安裝包

tar -zxf node-v0.10.24.tar.gz
cd node-v0.10.22/

3.編譯並安裝

./configure –prefix=/opt/nodejs      #這裡可以不指定目錄,直接執行./configure命令也可以。
make                                              #這裡有些慢,需要耐心等待
make install

4,測試安裝

輸入node --version測試是否安裝成功,若顯示版本號碼表示安裝成功,以下是node相關參數

anwj@Anwj:~/nodejs$ node --help
Usage: node [options] [ -e script | script.js ] [arguments] 
       node debug script.js [arguments] 


Options:
  -v, --version        print node's version
  -e, --eval script    evaluate script
  -p, --print          evaluate script and print result
  -i, --interactive    always enter the REPL even if stdin
                       does not appear to be a terminal
  --no-deprecation     silence deprecation warnings
  --trace-deprecation  show stack traces on deprecations
  --v8-options         print v8 command line options
  --max-stack-size=val set max v8 stack size (bytes)


二,npm(node package manager)

你只需要執行以下命令:
1.curl http://npmjs.org/install.sh | sh

如果安裝過程中出現了許可權問題,那麼需要在 root 許可權下執行上面的語句,或者使用sudo。
curl http://npmjs.org/install.sh | sudo sh
2其他安裝方法,譬如從 git 中擷取 npm 的最新分支,可以參考 http://npmjs.org/doc/README.html上的說明。

聯繫我們

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