【发布时间】:2018-06-15 09:29:07
【问题描述】:
我的 browsersync 使用 npm 时出现问题。当我想启动 browsersync 时,它显示“listing directory /”而不是我的 index.html。当我单击 index.html 时,它显示无法获取 /index.html。有什么问题?
【问题讨论】:
标签: npm browser-sync
我的 browsersync 使用 npm 时出现问题。当我想启动 browsersync 时,它显示“listing directory /”而不是我的 index.html。当我单击 index.html 时,它显示无法获取 /index.html。有什么问题?
【问题讨论】:
标签: npm browser-sync
我找到了一个修复程序,它对我有用,所以我会在这里为遇到同样问题的任何人发布一个解决方案:)
所以很简单,我的 package.json 脚本中有:
"watch:browsersync": "browser-sync start --server --files \"css/*.css\" \"*.html\" --serveStatic \"./\""
为了解决我的问题,我添加了最后一个:
--serveStatic \"./\""
它解决了我的问题:)
【讨论】:
browser-sync --cwd
这似乎是正确的命令。 “cwd”代表当前工作目录。我使用的是 2.26.7 版本
看来你需要运行命令browser-sync start然后你需要停止进程然后使用cwd命令。
【讨论】: