Home

Issue: 867

importing router instance using alias not working properly

[issue link]

I’m using the example ga implementation from the nuxt official website

when I use import router from '~router' and define router.afterEach, I get this error:

[nuxt.js] Cannot load components TypeError: Cannot read property 'afterEach' of undefined

when I use const router = require('~router'), I get this error:

[nuxt.js] Cannot load components TypeError: __webpack_require__(...) is not a function

Question: how to properly import router instance to get google analytics working?

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