I follow the tutorial of google analytics on website but doesn't work. I've a warning saying could find '~router'. I try also on a new default project and also doesn't work.
Could someone please help me on this? I've trying to fix this issue since 3 days without success
export 'default' (imported as 'router') was not found in '~router'
, I get this when running the npm run build
I just discovered the same issue after upgrading to 1.0.0-alpha1 this morning.
See #754 for a preview of the changes in 1.0.0-alpha1. Looks like the updated documentation is in progress.
Plugins now need to export a function. You can access the router from app.router
inside the function you export. See https://github.com/nuxt/nuxt.js/blob/dev/examples/i18n/plugins/i18n.js for an example of how to get the app instance within a plugin.
You could also downgrade to v0.10.7 and it should work exactly the same as the example in the current documentation.
@creativecoder I solve by using const router = require('~router')
and then router.createRouter().afterEach..
, isn't the best solution. I'll not close since I think is a bug from the upgrade.
@jdinartejesus But directly require ~router
is wrong!! Consider that module is shared across SSR requests. You may expose a default function in your plugin and getting router instance for each request like this:
export default ({app: {router}, store}) => {
// router is available
}
https://nuxtjs.org/faq/google-analytics/#how-to-use-google-analytics- @pi0 I'm just following the tutorial from Nuxtjs
@pi0 Thanks for that tip--worked well for me in upgrading to 1.0.0-alpha1
@jdinartejesus What version are you using? The current docs at nuxtjs.org are for v0.10.7 (the previous release) and haven't been updated yet for 1.0.0-alpha1 (current release, just released earlier this week). 1.0.0-alpha1 has breaking changes, some of them outlined in #754
I'm working on modular integration for google-analytics. Will be available in less than 1 hour.
Ah ok I see, that's cool. I wasn't aware of the updated. I'll update then my settings for the router.
Thanks @pi0 and @creativecoder
google analytics module is available now. Please give your feedback as i haven't heavily tested it.
@pi0 Does the module works with version Nuxt 0.10.7?
Unfortunately no. Modules integration are available from 1.0.0-alpha
. (Yet another reason to upgrade :P)
:/ I can't, because doesn't work to me 30
@pi0 do you have plans also to support Google Tag Manager? Btw thanks so much for the Google Analytics I'll update! 馃憤
@jdinartejesus Feel free opening an Issue in modules repo. We may add support for tags manager too :)
Great @pi0, I already change my code with the module and everything is working fine. We can close this issue then.
thx @pi0 - the mentioned workaround does the trick for me @ 0.10.7
.
Is there any doc / information around _new_ modules concept already by the way?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
google analytics module is available now. Please give your feedback as i haven't heavily tested it.