【问题标题】:Browser-sync Cannot GET /浏览器同步无法获取 /
【发布时间】:2018-05-24 04:53:58
【问题描述】:

我刚刚安装了浏览器同步,但是当我尝试启动服务器时出现此错误:

      terkea@terkea-Lenovo-G50-80:~$ browser-sync start --server --files index.html[Browsersync] Access URLs:

   Local: http://localhost:3000
External: http://192.168.1.3:3000
------------------------------------
      UI: http://localhost:3001
UI External: http://192.168.1.3:3001
------------------------------------

[Browsersync] 提供来自:./ 的文件 [Browsersync] 正在观看文件...

也许有人可以找出问题所在并帮助我?

【问题讨论】:

  • 错误是什么?
  • 当我打开浏览器时,我得到 CANNOT GET/ 而不是我的 index.php
  • 我不明白,请将错误添加到您的问题中,而不是评论它
  • 你用过浏览器同步吗?
  • 是的,我做到了。但我不明白你做了什么来引发错误。

标签: html node.js ubuntu synchronization browser-sync


【解决方案1】:

您必须指定文件所在的文件夹。我使用 ubuntu 18.04,它可以工作。 例如,如果要打开目录 /home/user/code 中的所有文件,则必须编写以下命令:

browser-sync start --server "/home/user/code/" --files "*.*"

【讨论】:

  • UPD: 一个小的修正 - 只有当您进入项目的布局并从那里启动程序时才能正常工作。例如:cd /home/user/code browser-sync start --server --files "*.*"
【解决方案2】:

您可能需要将参数传递给 --server,这是您要从中提供文件的目录。 Browser-sync 默认使用你当前的工作目录。

例如,如果您在项目的根目录中启动 browser-sync,并且 index.html 位于文件夹 a/b/c/index.html 中,那么 browser-sync 命令将是:

browser-sync start --server "a/b/c/" --files "index.html"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-25
    • 2017-06-08
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 2016-05-11
    • 2018-06-15
    • 1970-01-01
    相关资源
    最近更新 更多