我正在尝试将这个使用 NextJS 和 Firebase 构建的 Web 应用程序部署到 Firebase 托管。部署过程因意外错误而终止。
在搜索日志并在 Google 上检查它们后,我发现 4 月份发布的 GitHub 解决了同样的问题。显然这与 Firebase CLI 如何从 NextJS AppRouter 提取路由信息有关。我已尝试下载建议的修复程序,但它不可用。经过进一步研究,我发现了一个解决上述问题的提交。更新 Firebase CLI 没有带来任何结果
Web 应用程序基本上是一个简单的 CRUD CMS,它允许在页面的每个部分内创建页面,以及插入简单的图像和文本数据。任何地方都没有做任何花哨的事情。
我没有包含日志或配置文件,因为显然这是一个解决常见用例的已知问题。
编辑: 环境信息:
CLI Version: 11.27.0
Platform: linux
Node Version: v16.16.0
package.json
{
"name": "andreia-pinho",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"autoprefixer": "10.4.14",
"bootstrap": "^5.3.2",
"eslint": "8.44.0",
"eslint-config-next": "13.4.10",
"firebase": "^10.6.0",
"firebase-tools": "^12.9.1",
"next": "^13.4.19",
"postcss": "8.4.26",
"react": "18.2.0",
"react-bootstrap": "^2.9.0",
"react-dom": "18.2.0",
"tailwindcss": "3.3.3"
}
}
firebase.json
{
"hosting": {
"source": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"frameworksBackend": {
"region": "europe-west1"
}
}
}
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
images:{
unoptimized: true
}
}
module.exports = nextConfig
firebase-debug.log
[debug] [2023-11-16T23:15:58.693Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2023-11-16T23:15:58.693Z] > authorizing via signed-in user ([email protected])
[debug] [2023-11-16T23:15:58.693Z] [iam] checking project andreia-pinho for permissions ["firebase.projects.get","firebasehosting.sites.update"]
[debug] [2023-11-16T23:15:58.695Z] >>> [apiv2][query] POST https://cloudresourcemanager.googleapis.com/v1/projects/andreia-pinho:testIamPermissions [none]
[debug] [2023-11-16T23:15:58.695Z] >>> [apiv2][(partial)header] POST https://cloudresourcemanager.googleapis.com/v1/projects/andreia-pinho:testIamPermissions x-goog-quota-user=projects/andreia-pinho
[debug] [2023-11-16T23:15:58.695Z] >>> [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/andreia-pinho:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[debug] [2023-11-16T23:15:59.512Z] <<< [apiv2][status] POST https://cloudresourcemanager.googleapis.com/v1/projects/andreia-pinho:testIamPermissions 200
[debug] [2023-11-16T23:15:59.512Z] <<< [apiv2][body] POST https://cloudresourcemanager.googleapis.com/v1/projects/andreia-pinho:testIamPermissions {"permissions":["firebase.projects.get","firebasehosting.sites.update"]}
[debug] [2023-11-16T23:15:59.516Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/andreia-pinho [none]
[debug] [2023-11-16T23:16:00.014Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/andreia-pinho 200
[debug] [2023-11-16T23:16:00.014Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/andreia-pinho {"projectId":"andreia-pinho","projectNumber":"794238121312","displayName":"andreia-pinho","name":"projects/andreia-pinho","resources":{"hostingSite":"andreia-pinho","realtimeDatabaseInstance":"andreia-pinho-default-rtdb","storageBucket":"andreia-pinho.appspot.com","locationId":"europe-west"},"state":"ACTIVE","etag":"1_24c6b28a-b308-40d1-a0a6-0e9e6c03c54c"}
[debug] [2023-11-16T23:16:03.711Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/andreia-pinho/sites pageToken=&pageSize=10
[debug] [2023-11-16T23:16:05.128Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/andreia-pinho/sites 200
[debug] [2023-11-16T23:16:05.128Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/andreia-pinho/sites {"sites":[{"name":"projects/andreia-pinho/sites/andreia-pinho","defaultUrl":"https://andreia-pinho.web.app","appId":"1:794238121312:web:faf24b316f832b9ecbda05","type":"DEFAULT_SITE"}]}
[debug] [2023-11-16T23:16:05.129Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:794238121312:web:faf24b316f832b9ecbda05/config [none]
[debug] [2023-11-16T23:16:05.824Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:794238121312:web:faf24b316f832b9ecbda05/config 200
[debug] [2023-11-16T23:16:05.824Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/-/webApps/1:794238121312:web:faf24b316f832b9ecbda05/config {"projectId":"andreia-pinho","appId":"1:794238121312:web:faf24b316f832b9ecbda05","databaseURL":"https://andreia-pinho-default-rtdb.europe-west1.firebasedatabase.app","storageBucket":"andreia-pinho.appspot.com","locationId":"europe-west","apiKey":"AIzaSyC8Spdjk3CnpNJpEn2P-WQDcqn8DWEbWwc","authDomain":"andreia-pinho.firebaseapp.com","messagingSenderId":"794238121312","measurementId":"G-HMCYZBRY6J"}
[debug] [2023-11-16T23:16:30.885Z] TypeError: Cannot read properties of null (reading 'endsWith')
at ɵcodegenPublicDirectory (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/next/index.js:206:56)
at async prepareFrameworks (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/frameworks/index.js:287:13)
at async deploy (/home/pbarbeira/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/deploy/index.js:53:13)
[error]
[error] Error: An unexpected error has occurred.
这两件事应该可以解决您的问题:
next
版本更新为 13.5.6
swcMinify: false
添加到next.config.js
:/** @type {import('next').NextConfig} */
module.exports = {
swcMinify: false
.... other props
}