Static GitHub Issues

[1997] Uncaught ReferenceError from plugin file

prev: [Request] Ability to cancel navigation from asyncData without error page
next: What is the best method to integrate a vuejs composent to nuxtjs ?

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?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1772">#c1772</a>)</em></sub></div>