我正在使用 Firebase Hosting 部署我的网络应用程序,它使用 NextJS。在 2023 年 3 月下旬的最后一次部署中,我能够通过以下步骤进行部署,但现在我收到一个错误,其中找不到
pages
目录,即使我在项目的根目录下运行 deploy 命令,其中 pages
是。
firebase deploy --only hosting
但是运行Firebase命令,进程成功启动其他Firebase服务。
+ functions: .firebase\myprojectprod\functions folder uploaded successfully
i hosting[myprojectprod]: beginning deploy...
i hosting[myprojectprod]: found 109 files in .firebase\myprojectprod\hosting
+ hosting[myprojectprod]: file upload complete
i functions: updating Node.js 16 function firebase-frameworks-myprojectprod:ssrmyprojectprod(us-central1)...
Build failed with status: FAILURE and message: > [email protected] build
> next build
...
> Build error occurred
Error: > Couldn't find a `pages` directory. Please create one under the project root
Error 似乎说应用程序的构建错误但是当我运行时构建成功
npm run build && npm run start
.
firebase.json
{
"hosting": {
"source": ".",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"frameworksBackend": {
"region": "us-central1"
}
},
"firestore": {
"rules": "firestore.rules"
}
}
next.config.js
module.exports = withBundleAnalyzer({
transpilePackages: ["@stripe/firestore-stripe-payments"],
i18n: {
locales: ["en"],
defaultLocale: "en"
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "storage.googleapis.com",
pathname: `/my-bucket`,
},
],
},
devIndicators: {
buildActivity: false,
},
})
项目目录
pages/
blogs/
[blogId].tsx
blog-index.tsx
index.js
catalog.tsx
login.tsx
account.tsx
404.js
500.js
public/
favicon.ico
images/
icon1.png
themes/
firebase.json
package.json
tsconfig.json
firestore.rules
firebase.ts
.env.production
.env.local
css/
components/
...
firebase_utils/
...
我试过了
firebase experiments:enable webframeworks
"public": "public"
中的firebase.json
选项因为documentation说它是必需的(我不认为它是)