ubantu安裝node、npm、cnpm、live-server


 

更新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

安裝最新的nodejsstable版本)

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM