Home

Issue: 1997

Uncaught ReferenceError from plugin file

[issue link]

I have a working page outside of Nuxt. When I bring it into Nuxt, the JS as a plugin, I get an Uncaught ReferenceError: i is not defined error.

The i refers to this, and is related to the Hooks of this script.

That’s not my code, but as I say, it is working in my non Nuxt implementation. The same thing in Nuxt gives the error.

In the Nuxt version I have:

  • saved the script in the plugins directory
  • added it to the config plugins, using ssr: false
  • initialised it on the page inside mounted: () => {

It works if I remove the parts of my code utilising the hooks, but outside of Nuxt it all works. Why would this be?

This question is available on Nuxt.js community (#c1772)