[英]Lite-server does not detect a `bs-config.json` or `bs-config.js` override file
I'm trying to run angular2 based first app. 我正在尝试运行基于angular2的第一个应用程序。 I followed angular2 steps. 我跟着angular2步骤。 When i run command npm start
then its giving following error in the terminal 当我运行命令npm start
然后它在终端中给出以下错误
Did not detect a bs-config.json or bs-config.js override file. 没有检测到bs-config.json或bs-config.js覆盖文件。 Using lite-server defaults... 使用lite-server默认值...
And also browser returning 404 error
for index.html file ( angular-project/app/index.html
) 并且浏览器返回了index.html文件的404 error
( angular-project/app/index.html
)
I check lite-server version is "lite-server@^2.2.0",
and npm version 3.7.3
, also i followed this accepted answer instructions but still facing same issue. 我检查lite-server版本是"lite-server@^2.2.0",
和npm版本3.7.3
,我也按照这个接受的答案说明但仍面临同样的问题。 Can anyone guide me how can fix it, I will appreciate. 任何人都可以指导我如何解决它,我会很感激。 Thank You. 谢谢。
In Wrap up section different project structure than described in question. 在Wrap up部分中,不同的项目结构比有问题的描述。 Please ensure that you have followed tutorial correctly. 请确保您已正确使用了教程。
I see you are running lite-server 2.2.0; 我看到你正在运行lite-server 2.2.0; anyone else looking for help with this error should make sure they are running lite-server 2.0 or greater as that's when config file support was introduced. 任何寻求这个错误帮助的人都应该确保他们在引入配置文件支持时运行lite-server 2.0或更高版本。
Also, it can throw this error if there is a problem executing the bs-config.js, so check your config file for anything that could be erroring (including but not limited to syntax errors). 此外,如果是执行BS-config.js一个问题它可以抛出这个错误,所以请检查您的配置文件的任何可能被示数(包括但不限于语法错误)。 For me I had forgotten to install the http-proxy-middleware
so lite-server errored when it tried to execute the first line of my bs-config.js, which was var proxy = require('http-proxy-midleware');
对我来说,我忘了安装http-proxy-middleware
因此当它试图执行我的bs-config.js的第一行时,错误的是lite-server,这是var proxy = require('http-proxy-midleware');
. 。 An npm install --save-dev http-proxy-middleware
fixed this error for me. 一个npm install --save-dev http-proxy-middleware
为我修复了这个错误。
The reason that you have seen this warning message 您看到此警告消息的原因
Did not detect a bs-config.json or bs-config.js override file. 没有检测到bs-config.json或bs-config.js覆盖文件。 Using lite-server defaults... 使用lite-server默认值...
is probably that you have a definition in your package.json
which describes what should happen once you trigger the npm start
command, like: 可能你的package.json
有一个定义,它描述了一旦你触发npm start
命令会发生什么,比如:
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server -c bs-config.json\" ",
...
}
Therefore, in short you need to either provide the bs-config.json
file with the desired browser-sync configuration or modify the the above command. 因此,简而言之,您需要使用所需的浏览器同步配置提供bs-config.json
文件或修改上述命令。
Moreover, angular2 has now its famous quick-start example on github. 此外,angular2现在在github上有着名的快速启动示例。
I made this account specifically to second the answer made by Patrick on July 12th. 我专门用这个帐号来说明帕特里克7月12日的回答。
If your bs-config cannot be found it may be because you do not have the proper packages. 如果找不到你的bs-config,可能是因为你没有合适的软件包。 In my case I had http-proxy-middleware
, but was missing connect-history-api-fallback
. 在我的情况下,我有http-proxy-middleware
,但缺少connect-history-api-fallback
。
Make sure to check/install all the node packages used in your bs-config! 确保检查/安装bs-config中使用的所有节点包!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.