question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$fireMess undefined in production mode

See original GitHub issue

Version

@nuxtjs/firebase: ^5.0.7 firebase: ^7.14.2 nuxt: 2.11.0

Reproduction Link

https://firebase.nuxtjs.org/guide/usage/#general-usage

Steps to reproduce

  1. Setup Nuxt JS project and install Firebase and the Firebase Module, set to universal mode.
  2. Setup config of module with the following services object:
services: {
  messaging: true
}
  1. The following code is added for token refresh:
var messaging = this.$fireMess;

messaging.onTokenRefresh(() => {
  ...
});

What is Expected?

this.$fireMess should be defined in production Nuxt JS.

What is actually happening?

this.$fireMess is undefined in production mode of Nuxt JS.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lupascommented, Apr 25, 2020

nuxt start doesn’t technically reproduce that of a traditional web server

You’re right, but it runs nuxt in production mode, which is what you named as the issue, so I used it to quickly check if it’s just that.

but try building and then run npm run generate or nuxt generate afterwards.

If you read my message you see that after that I did nuxt generate and deployed the static html, and did not run into the issue. So a productive generate deployment works, too.

So that way I could assume it’s something related to your setup.

In any case, the information that you run into troubles running it with MAMP Pro is valuable. So I installed MMAP Pro, set up a host, ran it, and: Got same issue as you. Finally =)

Now MAMP Pro doesn’t run any SSL just like that, which is needed for Firebase Messaging to work.

So I did:

  1. Host -> SSL
  2. Create self-signed certificate…
  3. Add something random

Restarted the server and it worked.

Let me know if that does anything for you.

1reaction
lupascommented, Apr 24, 2020

@sts-ryan-holton

So I just did the following:

  mounted() {
    console.log("FIRE MESSAGING", this.$fireMess)
  },
  • nuxt build and then
  • nuxt start

And it wasn’t undefined in production mode: Screenshot 2020-04-24 at 23 24 40

So to see if a generated & deployed Nuxt generate behaves the same way, I deployed a static site to Firebase:

yarn run generate && firebase deploy --only hosting --project nuxt-fire-demo

https://nuxt-fire-demo.web.app/ Also works…

So there must be something off with your config, or your environment (e.g. your browser) where you test it. Know that messaging is not supported on all browsers, so it doesn’t get initialized if the browser doens’t support it.

Though I assume you tested it on the same browser in dev and prod so that’s probably not it either…

Btw here is the branch of the demo on which I tested it out, maybe the code there helps you to find the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack production mode - NODE_ENV undefined
Way I found is to use argv.mode variable inside export like so: module.exports = (env, argv) => { const isDevelopment = argv.mode !==...
Read more >
Production Mode : ERROR TypeError: Cannot read property of ...
I m trying to use Schedule in my Angular App. In Developpment mode every thinks works perfectly. But in Production mode, I'm able...
Read more >
3/1/11 - Ron Martinsen's Photography Blog
To turn my print into a scanned image, I started by using EPSON Scan in Professional Mode using values I thought an average...
Read more >
My script is working on development mode but not o...
Hello, I have added my custom script in footer That script is working on development mode, but not on production mode it gives...
Read more >
Vue 3 production mode makes `this` undefined - Get Help
For this code: https://codesandbox.io/s/crazy-worker-kkq1c (once deployed: https://csb-kkq1c.netlify.app/) I can see that var t = this; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found