[英]Specified "public" directory {path} does not exist
I am trying to add Hosting to an existing firebase app that has Functions up and running.我正在尝试将托管添加到现有的 firebase 应用程序,该应用程序已启动并运行功能。 I intended to host a react app that consume my existing functions.我打算托管一个使用我现有功能的反应应用程序。 The public directory I chose for hosting is /{react-project-root-folder}/build.我选择用于托管的公共目录是 /{react-project-root-folder}/build。
I followed this answer to add hosting.我按照这个答案添加了托管。
When I am running firebase deploy
, it gives the error当我运行firebase deploy
时,它给出了错误
Error: Specified "public" directory "/view/build" does not exist, can't deploy hosting to site {app-name}
Even though the folder exists.即使该文件夹存在。
Can you help me spot what I did wrong?你能帮我找出我做错了什么吗? Should I choose another folder?我应该选择另一个文件夹吗?
My folder structure:我的文件夹结构:
Firebase Practice
|__ functions
|__ .firebase.json
|__ .firebaserc
|__ view
|__ build
|__ static/js
|__ index.html
|__ node_modules
|__ public
|__ src
Image of folder structure:文件夹结构图:
firebase.json: firebase.json:
{
"functions": {
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"source": "functions"
},
"hosting": {
"public": "/view/build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/api/*",
"function": "api"
},
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Turn out you do not need the first /
on your public path.原来你不需要公共路径上的第一个/
。
Corrected firebase.json:更正了 firebase.json:
{
"functions": {
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"source": "functions"
},
"hosting": {
"public": "view/build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.