进入你的网站项目目录 cd xxx
$npm install browser-sync —save -d
$ find node_modules
可以查看browser-sync包被安装的目录
运行git diff 可以看到package.json
$git diff
运行 $npm ls
可以查看依赖树
检查 browser-sync 版本
$ ./node_modules/.bin/browser-sync —version
添加环境变量,回到项目目录 执行
$ export PATH=$PATH:./node_modules/.bin
再 执行 $ browser-sync —version 看是否生效
使用
启动服务
$ browser-sync start --server --files=index.html
你对index.html的修改可以实时提现在浏览器http://localhost:port 上
方法二
安装 BrowserSync (依赖 NodeJS):
npm install browser-sync@2.7.1 然后在项目目录运行这个命令:
browser-sync start --server --port 4000 --files index.html --files css/main.css 这样页面就会自动刷新了。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有