【问题标题】:Browser-sync + npm not working properly浏览器同步 + npm 无法正常工作
【发布时间】:2018-06-15 09:29:07
【问题描述】:

我的 browsersync 使用 npm 时出现问题。当我想启动 browsersync 时,它显示“listing directory /”而不是我的 index.html。当我单击 index.html 时,它显示无法获取 /index.html。有什么问题?

【问题讨论】:

    标签: npm browser-sync


    【解决方案1】:

    我找到了一个修复程序,它对我有用,所以我会在这里为遇到同样问题的任何人发布一个解决方案:)

    所以很简单,我的 package.json 脚本中有:

        "watch:browsersync": "browser-sync start --server --files \"css/*.css\" \"*.html\" --serveStatic \"./\""
    

    为了解决我的问题,我添加了最后一个:

     --serveStatic \"./\""
    

    它解决了我的问题:)

    【讨论】:

      【解决方案2】:
      browser-sync --cwd
      

      这似乎是正确的命令。 “cwd”代表当前工作目录。我使用的是 2.26.7 版本

      看来你需要运行命令browser-sync start然后你需要停止进程然后使用cwd命令。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-14
        • 2013-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-11
        • 2015-08-13
        • 1970-01-01
        相关资源
        最近更新 更多