跳到主要內容

[Linux] Ubuntu 安裝Node.JS開發環境

基本操作 - Basic instruction

先利用apt-get去安裝git的程式,以便獲得後續更多的bin檔案進行安裝
apt-get: Binary package management
$ which git
$ sudo apt-get install -y git-core
$ which git
/usr/bin/git


伺服器用的JavaScript - Basic Server-Side JS (SSJS)
安裝用在server端的JavaScript,也就是本文使用的Node.JS
$ sudo apt-get update
# Install a special package
$ sudo apt-get install -y python-software-properties python g++ make
# Add a new repository for apt-get to search
$ sudo add-apt-repository ppa:chris-lea/node.js
# Update apt-get’s knowledge of which packages are where
$ sudo apt-get update
# Now install nodejs and npm
# sudo apt-get install -y nodejs

1.sudo apt-get install -y python-software-properties python g++ make
先安裝python以及g++



2.sudo add-apt-repository ppa:chris-lea/node.js
利用網路上所開放的資料庫伺服器(repository),更新apt中Node.JS的安裝包

3.sudo apt-get update
更新ubuntu中的安裝檔案列表 

4.sudo apt-get install -y nodejs
安裝Node.JS

確認版本 - Check Node.JS Version
npm為node.js用來管理模組(module)的管理員,是官方在維護的library
Node的版本

$ npm --version
1.2.32
$ node --version
v0.10.12


執行Node.JS - Run Node

>1+1
2
> var test = "qwe";
undefined
> test
'qwe'



留言