Linux 安裝nodejs環境以及路徑配置

來源:互聯網
上載者:User

標籤:系統   檢查   style   nodejs   進入   cache   global   路徑   環境   

linux安裝nodejs有2種方式一種簡單的,解壓即可用;另一種,通過下載source code ,通過編譯,make,make install命令來安裝。

  這裡只講第一種,簡單方便。不需要執行mak、make install。步驟如下:

一、確定你使用的linux系統,然後下載響應的壓縮包。這裡我下載的是node-v6.11.2-linux-x64.tar.xz

二、上傳到linux相關路徑下,一般是/usr/local/,並執行如下命令

   xz -d node-xxxx.tar.xz ---將tar.xz解壓成tar檔案

   tar -xvf node-xxxx.tar ---將tar檔案解壓成檔案夾

  mv node-xxx node ----改檔案夾的名字,改成node

三、檢查是否可以安裝成功

 

四、配置軟串連,使全域都可以使用node命令

ln -s /usr/local/node/bin/node /usr/bin/node  --將node源檔案對應到usr/bin下的node檔案

ln -s /usr/local/node/bin/npm /usr/bin/npm

五、配置node檔案安裝路徑

進入/usr/local/node/路徑下:

mkdir node_global

mkdir node_cache

npm config set prefix "node_global"

npm config set cache "node_cache"

 

六、當你覺得npm慢的時候,可以安裝cnpm

npm install cnpm -g --registry=https://registry.npm.taobao.org

順便可以檢查一下-g這個全域安裝有沒有按照之前設定的,安裝到node_global檔案下。

如下全域使用cnpm,也要記得配置一個軟串連。

 

 

Linux 安裝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.