nuxt / vue-meta

Manage HTML metadata in Vue.js components with SSR support
https://vue-meta.nuxtjs.org
Other
4.08k stars 247 forks source link

[Version ^3.0.0-alpha.2] Cannot read property 'resolve' of undefined with Vue3 in SSR mode #718

Open oom- opened 3 years ago

oom- commented 3 years ago

Hello,

I'm trying to make work vue-meta with Vue3 in SSR mode (https://github.com/nuxt/vue-meta/tree/next#ssr)

Everything build just fine, I can start my express server and all but when I'm accessing a page I'm getting this error:

[Vue warn]: Unhandled error during execution of setup function
  at <App>
(node:24140) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'resolve' of undefined
    at Object.resolve (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:845:25)
    at recompute (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:274:32)
    at compute (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:434:27)
    at Object.addSource (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:441:17)
    at MetaManager.addMeta (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:757:34)
    at useMeta (F:\Documents\website\node_modules\vue-meta\dist\vue-meta.cjs.js:691:31)
    at setup (F:\Documents\website\dist\server\js\app.514800de.js:1622:42)
    at callWithErrorHandling (F:\Documents\website\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6919:22)
    at setupStatefulComponent (F:\Documents\website\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6537:29)
    at setupComponent (F:\Documents\website\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6493:11)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24140) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:24140) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This line trigger the error in vue-meta.cjs.js: image

I tried to add the metaManager in the context (in case of): image

Inside the createApp function there is nothing special : image

And here is my App.vue file where the error is triggered : image

(Do not pay attention to the extra console.log I was checking that nothing was undefined.)

Does someone have an idea about what is going wrong here? 😕

Thank you.

alowave223 commented 3 years ago

bump

Nalem14 commented 3 years ago

Same here

noxsii commented 3 years ago

same

alvarosabu commented 2 years ago

same issue here without the SSR

danken00 commented 2 years ago

Me too. Did anyone find a workaround for this?

braitsch commented 2 years ago

This error will go away if you use v3.0.0-alpha.10 but I still can't get vue-meta to work in a brand new project regardless.

numver commented 2 years ago

Same here

stale[bot] commented 2 years ago

Thanks for your contribution to vue-meta! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of vue-meta
  2. Comment the steps to reproduce it Issues that are labeled as pending will not be automatically marked as stale.
Rathanavel commented 2 years ago

Same here.

renatosaz commented 2 years ago

same here

therealbenzene commented 2 years ago

Same here

wesly1988 commented 2 years ago

same here

twentytwo777 commented 2 years ago

same here

JPaezMin commented 2 years ago

same heve for a vite + vue 3 environment.

hsyir commented 1 year ago

same

roarkmccolgan commented 1 year ago

SAme

sadrahoseini commented 1 year ago

same for vie + vue 3

DengSihan commented 1 year ago

same here vite+vue3

staszek998 commented 1 year ago

I think I've found the source of the problem, as well as the solution:

TL;DR: Verify that you've got the correct version of the vue-meta package installed in your project.

For some reason, when you run the npm install vue-meta@next --save command (as instructed by the docs from the homepage), the NPM installs the vue-meta package with the version set to ^3.0.0-alpha.2. However, when you look at the Releases page, it's obvious that the newest release is 3.0.0-alpha.8. Given this information, when you manually set the package version in the package.json to ^3.0.0-alpha.8 and run the npm install command, the problem goes away; NPM updates the vue-meta package, and the createMetaManager() function behaves as expected 🙂


CC: @pimlie ('cause you seem to maintain the README.md file for the next branch)

Muhand commented 1 year ago

I think I've found the source of the problem, as well as the solution:

TL;DR: Verify that you've got the correct version of the vue-meta package installed in your project.

For some reason, when you run the npm install vue-meta@next --save command (as instructed by the docs from the homepage), the NPM installs the vue-meta package with the version set to ^3.0.0-alpha.2. However, when you look at the Releases page, it's obvious that the newest release is 3.0.0-alpha.8. Given this information, when you manually set the package version in the package.json to ^3.0.0-alpha.8 and run the npm install command, the problem goes away; NPM updates the vue-meta package, and the createMetaManager() function behaves as expected 🙂

CC: @pimlie ('cause you seem to maintain the README.md file for the next branch)

@staszek998 this fixes the problem. Indeed npm install vue-meta@next is installing alpha.2