--- tags: node.js, ubuntu16.04 --- # 安裝 nodeJS :::info - 環境: ubuntu16.04 ::: ## 方法 1. 使用 ubuntu 的套件庫進行安裝,一行指令安裝 (由於此安裝方法的來源為 ubuntu 維護, nodejs 版本可能會比較低) ```shell sudo apt-get install nodejs sudo apt-get install nodejs-legacy sudo apt-get install npm ``` :::success 由於 nodejs 安裝完後會產生執行檔 /usr/bin/nodejs,透過 node-legacy 會幫我們建立常見的 /usr/bin/node ::: 2. 透過 PPA (personal package archive) 安裝 ```shell curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - sudo apt-get install nodejs sudo apt-get install build-essential ``` :::success 1. 上述指令安裝版本為 6.x 2. 此方法已經幫你裝好 npm,不須另外再 apt install npm ::: 3. nvm 安裝,可以使用多版本的 nodejs 需求