【发布时间】:2016-08-01 23:33:03
【问题描述】:
我已将我的 Angular 应用程序部署到 Firebase。我可以正常看到登录页面,但重新加载页面时出现以下错误:
This file does not exist and there was no index.html found in the current directory or 404.html in the root directory.
Why am I seeing this?
You may have deployed the wrong directory for your application. Check your firebase.json and make sure the public directory is pointing to a directory that contains an index.html file.
You can also add a 404.html in the root of your site to replace this page with a custom error page.
因此,正如错误提示,我检查了我的 firebase.json 文件并显示如下:
{
"firebase": "******",
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
在这里你可以看到我的public 文件夹是我的dist 文件夹。这个dist 文件夹实际上是我在 gulp 构建所有文件时放置所有文件(css、js、html 和 index.html)的地方。文件夹结构如下所示:
dist
css
images
js
templates
index.html
所以上面的目标文件夹确实有一个index.html 页面 - 那为什么我会收到这个错误? Angular 应该介入并处理所有路由,但似乎并非如此。
编辑
【问题讨论】:
-
这里没有任何建议可以解决您的问题。一定有别的东西在起作用。您可以在部署中尝试 --debug 并准确查看正在上传哪些文件以及正在跳过哪些文件?
-
@Kato 我知道我上周问过这个问题,但你对这里发生的事情还有其他想法吗?