Lite-server 未检测到 `bs-config.json` 或 `bs-config.js` 覆盖文件

Lite-server does not detect a `bs-config.json` or `bs-config.js` override file

我正在尝试 运行 基于 angular2 的第一个应用程序。我遵循了 angular2 个步骤。当我 运行 命令 npm start 然后它在终端中给出以下错误

Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...

并且浏览器还为 index.html 文件 (angular-project/app/index.html)

返回 404 error

我检查 lite-server 版本是 "lite-server@^2.2.0", 和 npm 版本 3.7.3,我也遵循这个接受 但仍然面临同样的问题。谁能指导我如何解决它,我将不胜感激。谢谢。

Wrap up section 项目结构与问题中描述的不同。请确保您已正确遵循教程。

您看到此警告消息的原因

Did not detect a bs-config.json or bs-config.js override file. Using lite-server defaults...

可能是您在 package.json 中有一个定义,它描述了触发 npm start 命令后应该发生的情况,例如:

"scripts": {
  "start": "tsc && concurrently \"tsc -w\" \"lite-server -c bs-config.json\" ",
...
}

因此,简而言之,您需要为 bs-config.json 文件提供所需的浏览器同步配置,或者修改上述命令。

此外,angular2 现在在 github 上有其著名的 quick-start 示例。

我看到你是 运行 lite-server 2.2.0;任何寻求此错误帮助的人都应该确保他们是 运行 lite-server 2.0 或更高版本,因为那时引入了配置文件支持。

此外,如果执行 bs-config.js 时出现问题,它可能会抛出此错误,因此请检查您的配置文件中是否有任何 可能 出错的内容(包括但不限于语法错误)。对我来说,我忘记安装 http-proxy-middleware,所以当 lite-server 试图执行我的 bs-config.js 的第一行时出错,它是 var proxy = require('http-proxy-midleware');npm install --save-dev http-proxy-middleware 为我修复了这个错误。

HT:thisgithub问题。

为了附和帕特里克在7月12日的回答,特意建了这个账号。
如果找不到您的 bs-config,可能是因为您没有合适的软件包。就我而言,我有 http-proxy-middleware,但缺少 connect-history-api-fallback

确保 check/install 您的 bs-config 中使用的所有节点包!