1.創建一個 package.josn
文件:
npm init -y
2.安裝 browser-sync
:
npm install –save-dev browser-sync
3. 將 browser-sync 包保存到開發依賴中
就可以執行 npm install 的時候加入 –production 選項不安裝這個包
npm i -D browser-sync
4.在 package.json 文件中加入以下內容:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "browser-sync start --server --directory --files \"code/*.html\""
}
5.打開終端,啓動開發服務:
npm start