vue-meta icon indicating copy to clipboard operation
vue-meta copied to clipboard

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

Open oom- opened this issue 3 years ago • 20 comments

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.

oom- avatar Aug 30 '21 18:08 oom-

bump

alowave223 avatar Oct 11 '21 19:10 alowave223

Same here

Nalem14 avatar Nov 07 '21 03:11 Nalem14

same

noxsii avatar Nov 10 '21 07:11 noxsii

same issue here without the SSR

alvarosabu avatar Jan 13 '22 07:01 alvarosabu

Me too. Did anyone find a workaround for this?

danken00 avatar Feb 22 '22 05:02 danken00

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.

braitsch avatar Mar 23 '22 20:03 braitsch

Same here

numver avatar Mar 29 '22 02:03 numver

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.

stale[bot] avatar Apr 19 '22 17:04 stale[bot]

Same here.

Rathanavel avatar Apr 19 '22 17:04 Rathanavel

same here

renatosaz avatar Apr 22 '22 16:04 renatosaz

Same here

therealbenzene avatar May 02 '22 01:05 therealbenzene

same here

wesly1988 avatar Aug 16 '22 04:08 wesly1988

same here

twentytwo777 avatar Aug 16 '22 23:08 twentytwo777

same heve for a vite + vue 3 environment.

JPaezMin avatar Nov 02 '22 08:11 JPaezMin

same

hsyir avatar Jan 01 '23 12:01 hsyir

SAme

roarkmccolgan avatar Feb 06 '23 12:02 roarkmccolgan

same for vie + vue 3

sadrahoseini avatar Feb 12 '23 06:02 sadrahoseini

same here vite+vue3

DengSihan avatar Mar 14 '23 03:03 DengSihan

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 avatar Mar 29 '23 14:03 staszek998

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

Muhand avatar Jul 24 '23 02:07 Muhand