Ubuntu 12.04 安裝最新版本NodeJS

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   os   使用   sp   

昨天搭建了一個Windows NodeJS 運行環境,但Windows 運行NodeJS命令列各種彆扭,開源包的編譯也是各種問題,折磨了我一天一夜,果斷換到Linux 平台。。

我選擇了Ubuntu 12.04 ,直接 apt-get install nodejs,然後執行npm 命令,系統竟然提示 The program ‘npm‘ is currently not installed,那就apt-get install npm

,裝完發現版本不對。。。

# node -vv0.6.12# npm -v1.1.4

靠,一個小坑,解決方案參見:https://rtcamp.com/tutorials/nodejs/node-js-npm-install-ubuntu/

一步一步執行如下命令,問題解決:

# apt-get install python-software-properties# apt-add-repository ppa:chris-lea/node.js# apt-get update# apt-get install nodejs

 node,npm的問題解決。

還不算完,我使用 npm 安裝 pm2 包時又遇到一個問題:

[email protected] preinstall: `bash ./scripts/preinstall.sh`

在google 上找到解決方案:http://stackoverflow.com/questions/26731308/pm2-installation-results-in-error

此方案上說單獨安裝全域的pm2 包(另加unsafe-perm參數):

sudo npm install pm2 -g --unsafe-perm

但不是這麼簡單,我試了好多次,始終還是npm安裝pm2報錯,後來將 -g 參數去掉,變成這樣:

sudo npm install pm2 --unsafe-perm

問題搞定,導致此問題的原因: 可能是安裝到ubuntu系統上的全域npm包不被識別,需要配置node環境變數之類的,不管了,總之可以運行就OK,以後再細細研究~

Ubuntu 12.04 安裝最新版本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.