Nuxt-SEO icon indicating copy to clipboard operation
Nuxt-SEO copied to clipboard

Cannot read property '$options' of undefined

Open ghost opened this issue 4 years ago • 7 comments

Hello. I'm getting this error when i've created a fresh nuxt js project with latest version of library Cannot read property '$options' of undefined.

async asyncData({ $axios,seo }) { try { const home = await $axios.$get('/home'); seo({ name: 'Atlas', title: 'Home Page', templateTitle: '%name% - %title%', description: 'Hello World Page' }) return { home: home.responseData, }; } catch (e) { console.log(e) } },

when i was using '^1.3.1' version above code was working fine, now in newest version if i use above code, only seo details will be set, and i won't get my axios data to return home but i also get above cannot read property '$options' of undefined in console. if i use head context i'll only get cannot read property '$options' of undefined which app nuxt app gonna crush. this happen for other ways you mentioned in your examples.

api is also working fine, i tested above code with earlier version and it's worked. how to fix this?

ghost avatar Nov 06 '20 07:11 ghost

I'm facing this issue as well. I have downgraded nuxt from 2.14.7 to 2.14.0 and the error has disappeared. Seems like there may be internal variables that Nuxt-SEO has used, but perhaps have been removed in the latest Nuxt.

ceilfors avatar Nov 09 '20 09:11 ceilfors

A patch version (2.14.7) of nuxt has removed an extremely important context Vue.prototype.$nuxt. I will provide a fix as soon as possible.

https://github.com/nuxt/nuxt.js/pull/8170

TiagoDanin avatar Nov 14 '20 18:11 TiagoDanin

Hey my friend. i'm currently editing my videos for a premium course in udemy which i'm introducing your package there, so if you could fix this issues in early, i can edit the record video again instead of commenting since there's a conflict with nuxt version.

you can also reach to me via email ' [email protected] '. edit process might take almost 1-2~ week since there are more than 35 parts, and i'll publish course after that so if you could fix this, i can record this again.

Best Regards, Good Luck.

ghost avatar Nov 14 '20 18:11 ghost

Done in version 1.5.0

TiagoDanin avatar Nov 14 '20 18:11 TiagoDanin

Tested and works against nuxt 2.14.0.

ceilfors avatar Nov 18 '20 17:11 ceilfors

"nuxt": "2.14.11", "nuxt-seo": "1.5.0",

Cannot read property '$nuxt' of undefined 02:10:03

at create (.nuxt/Nuxt-Seo.js:185:0) at asyncData (index.vue:98:0) at promisify (.nuxt/utils.js:281:0) at server.js:4472:82 at Array.map () at module.exports../.nuxt/server.js.webpack_exports.default (.nuxt/server.js:254:0)

b-m-9 avatar Dec 10 '20 23:12 b-m-9

#109

TiagoDanin avatar May 20 '21 22:05 TiagoDanin