更新ubuntu軟件源
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
安裝nodejs
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm
更新npm的包鏡像源,方便快速下載
sudo npm config set registry https://registry.npm.taobao.org
sudo npm config list
全局安裝n管理器(用於管理nodejs版本)
sudo npm install n -g
安裝最新的nodejs(stable版本)
sudo n stable
sudo node -v
1:安裝node.js的版本控制工具nvm,在終端中執行:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
2:關閉終端后,重新進入終端,安裝node
nvm install node
3:安裝live-server:
npm install live-server
4:使用live-server
在前段文件中運行
live-server
node.js提供的服務器live-server的使用
安裝node.js的版本控制工具nvm,在終端中執行
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
重新進入終端,使用nvm安裝最新版本的node.js
nvm install node
安裝live-server
超級用戶下安裝下面的 不然報錯
npm install -g live-server
創建成功后,在靜態文件目錄下使用live-serverr就可以了
live-server運行在8080端口下,可以通過127.0.0.1:8080來訪問靜態頁面。
1:安裝node.js的版本控制工具nvm,在終端中執行:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
2:關閉終端后,重新進入終端,安裝node
nvm install node
3:安裝live-server:
npm install live-server
4:使用live-server
在前段文件中運行
live-server