LoginSignup
0
0

nuxtのssrをfirebase-hostingにデプロイする際にはまった内容のメモ

Posted at

firebase.jsonのpublicの指定

デプロイ後にモジュールが見つからないエラー

nuxtのプロジェクトのほうで利用しているdayjsのモジュールをそのままデプロイしたら以下のエラーが発生。


2021-01-29T01:32:54.301320235Z D ssr: Function execution started
2021-01-29T01:32:54.332Z ? ssr: in ssr
2021-01-29T01:32:54.341Z ? ssr:  ERROR  Cannot find module 'dayjs' from '/workspace'
2021-01-29T01:32:54.341Z ? ssr:   at Function.resolveSync [as sync] (node_modules/resolve/lib/sync.js:90:15)
2021-01-29T01:32:54.341Z ? ssr:   at node_modules/vue-server-renderer/build.prod.js:1:77685
2021-01-29T01:32:54.341Z ? ssr:   at Object. (webpack:/external "dayjs":1:0)
2021-01-29T01:32:54.341Z ? ssr:   at __webpack_require__ (webpack/bootstrap:25:0)
2021-01-29T01:32:54.341Z ? ssr:   at Module. (store/date.js:1:0)
2021-01-29T01:32:54.341Z ? ssr:   at __webpack_require__ (webpack/bootstrap:25:0)
2021-01-29T01:32:54.341Z ? ssr:   at updateModules (.nuxt/store.js:16:0)
2021-01-29T01:32:54.341Z ? ssr:   at Module. (.nuxt/store.js:19:0)
2021-01-29T01:32:54.341Z ? ssr:   at __webpack_require__ (webpack/bootstrap:25:0)
2021-01-29T01:32:54.341Z ? ssr:   at Object.module.exports.global.installComponents (server.js:563:18)
2021-01-29T01:32:54.437894913Z D ssr: Function execution took 137 ms, finished with status code: 500

firebase serveではエラーが出ずにそのまま使えるが、firebase deployしたあとにこのエラーが出てしまった。


2021-01-29T01:58:44.952Z ? ssr: in ssr
2021-01-29T01:58:44.968Z ? ssr:  ERROR  globalThis is not defined
2021-01-29T01:58:44.969Z ? ssr:   at Object. (node_modules/skyway-js/dist/skyway.js:14:4)
2021-01-29T01:58:44.969Z ? ssr:   at Module._compile (internal/modules/cjs/loader.js:778:30)
2021-01-29T01:58:44.969Z ? ssr:   at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
2021-01-29T01:58:44.969Z ? ssr:   at Module.load (internal/modules/cjs/loader.js:653:32)
2021-01-29T01:58:44.969Z ? ssr:   at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2021-01-29T01:58:44.969Z ? ssr:   at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2021-01-29T01:58:44.969Z ? ssr:   at Module.require (internal/modules/cjs/loader.js:692:17)
2021-01-29T01:58:44.969Z ? ssr:   at require (internal/modules/cjs/helpers.js:25:18)
2021-01-29T01:58:44.969Z ? ssr:   at node_modules/vue-server-renderer/build.prod.js:1:77662
2021-01-29T01:58:44.969Z ? ssr:   at Object. (webpack:/external "skyway-js":1:0)
2021-01-29T01:58:45.048568254Z D ssr: Function execution took 187 ms, finished with status code: 500

補足

ファイルコピー

サンプルのファイルコピーの仕組みが、cpコマンドで実装されていたため、Windowsのコマンドプロンプトでは動きませんでした。そのため、fs-extraというものを使い、スクリプトを書きました。


var fs = require('fs-extra')
const distPath = "./functions/ssr/dist"
const srcPath = "./.nuxt/dist"
fs.removeSync(distPath);
fs.mkdirsSync(distPath);
fs.copySync(srcPath, distPath);

firebase functionのdeploy時にエラー




!  functions[fns-updateMeeting(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=anomeet&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3Dbcc6f5ad-2911-4648-bedb-56ad9306ea5b%0AlogName%3Dprojects%2Fanomeet%2Flogs%2Fcloudbuild

"Step #3 - "restorer": [31;1mERROR: [0mfailed to restore: restoring data: GET https://storage.googleapis.com/us.artifacts.anomeet.appspot.com/containers/images/sha256:9c5fbd132c66e34a1fe8930c7a6befde60187a75ab9eefc2d5ecd70b495d268c?access_token=REDACTED: unsupported status code 404; body: NoSuchKeyThe specified key does not exist.No such object: us.artifacts.anomeet.appspot.com/containers/images/sha256:9c5fbd132c66e34a1fe8930c7a6befde60187a75ab9eefc2d5ecd70b495d268c"
insertId: "bcc6f5ad-2911-4648-bedb-56ad9306ea5b-177"

push.jsでserviceWorker.min.js

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0