【发布时间】:2022-11-02 02:23:53
【问题描述】:
我知道 Nuxt3 处于候选版本中,但它已被宣布为几乎稳定,因此我正在尝试使用云功能在 firebase 托管上部署我的 SSR 应用程序。
为此,由于我是 Nuxt 和 Firebase 环境的新手,我正在学习本教程:https://medium.com/@sirofjelly/deploying-a-nuxt-ssr-server-side-rendering-app-to-google-firebase-5d90117167db。
这是我的包.json:
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"firebase:start:import_export": "firebase emulators:start --import=./test/ --export-on-exit=./exported_datas/",
"firebase:export": "firebase emulators:export ./test/",
"deploy": "firebase deploy --only functions && firebase deploy --only hosting",
"clean": "rm -rf .nuxt .output dist node_modules *.log",
"clean_all": "npm run clean && rm -rf functions/node_modules functions/nuxt"
},
"devDependencies": {
"@intlify/unplugin-vue-i18n": "^0.5.0",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"autoprefixer": "^10.4.8",
"eslint": "^8.22.0",
"eslint-plugin-vue": "^9.3.0",
"nuxt": "^3.0.0-rc.11",
"postcss": "^8.4.16",
"vue-i18n": "^9.2.2"
},
"dependencies": {
"@headlessui/vue": "^1.6.7",
"@heroicons/vue": "^2.0.10",
"@nuxtjs/i18n": "^7.3.0",
"@sendgrid/mail": "^7.7.0",
"bulma": "^0.9.4",
"bulma-carousel": "^4.0.24",
"firebase": "^9.9.3",
"firebase-functions": "^3.23.0",
"firebase-tools": "^11.8.0",
"nuxt-start": "^2.15.8",
"uuid": "^8.3.2"
}
}
这是我的firebase.json文件:
{
"database": {
"rules": "./firebase_rules/database.rules.json"
},
"hosting": {
"predeploy": [
"rm -rf public/* && mkdir -p public/_nuxt && cp -r .nuxt/dist/client/ public/_nuxt && cp -a static/. public/"
],
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"function": "ssrapp"
}
]
},
"storage": {
"rules": "./firebase_rules/storage.rules"
},
"functions": {
"runtime": "nodejs16",
"source": "functions",
"predeploy": [
"npm run build && rm -rf functions/nuxt && cp -r .nuxt/ functions/nuxt/ && cp nuxt.config.ts functions/"
]
},
"emulators": {
"hosting": {
"port": 3001
},
"ui": {
"enabled": true
},
"database": {
"port": 9000
},
"storage": {
"port": 9199
},
"functions": {
"port": 5001,
"host": "localhost"
},
"auth": {
"port": 9099
}
}
}
观察到的行为:
当我运行构建命令npm run build 时,一切顺利,构建工作正常。
但是,当 predeploy 命令启动相同的构建命令时(请参阅函数配置中的 firebase.json),构建会引发特定错误:
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error:
Vue packages version mismatch:
- vue@3.2.41
- vue-server-renderer@2.7.13
https://github.com/nuxt/nuxt.js/issues/6823 没有解决我的问题
我用包尝试了很多东西,但没有成功。 有人有解决问题的想法吗?这是 Nuxt3-rc12 问题吗?
感谢帮助
【问题讨论】:
-
给定的文章已经很老了(2021 年)。我推荐使用这个解决方案:nitro.unjs.io/deploy/providers/firebase
-
不幸的是,本教程似乎涉及静态部署,我正在开发 SSR 应用程序
-
.output/server不是 SSR 吗? -
是的 !感谢帮助 !