nuxt-schema-org で head.use is not a function の対処

Published at: 2022/12/24


Nuxt 3 で schema.org を扱うには、公式 modules から紹介されている nuxt-schema-org が良さそうだったのでそれを使おうとした。 ドキュメント通りにセットアップしたはずのところ、以下のエラーが発生した。

[nuxt] [request error] [unhandled] [500] head.use is not a function
  at ./node_modules/nuxt-schema-org/dist/runtime/plugin.mjs:13:8
  at fn (./node_modules/nuxt/dist/app/nuxt.mjs:151:27)
  at Object.callAsync (./node_modules/unctx/dist/index.mjs:49:19)
  at callWithNuxt (./node_modules/nuxt/dist/app/nuxt.mjs:153:23)
  at applyPlugin (./node_modules/nuxt/dist/app/nuxt.mjs:97:29)
  at Module.applyPlugins (./node_modules/nuxt/dist/app/nuxt.mjs:107:11)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async createNuxtAppServer (./node_modules/nuxt/dist/app/entry.mjs:29:7)
  at async default (./node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:27:18)
  at async Object.renderToString (./node_modules/vue-bundle-renderer/dist/runtime.mjs:172:19)

解決法

head.use is not a function · Issue #1 · harlan-zw/unhead-schema-org · GitHub

Describe the bug Hello, just update my module but can't know what happened Reproduction Barbapapazes/le-classement.fr#79 System Info System: OS: Windows 10 10.0.19044 CPU: (4) x64 Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz Memory: 3.15 GB ...

github.com

の記事によれば、@vueuse/head に 1.0.22 で入った、head.use を利用可能にする修正を取り込む必要があることが分かる。 また同様に上記の記事より、このライブラリは nuxt 自身が引き連れてくる依存関係であるため、 yarn.lock を削除してライブラリを再インストールするとうまくいく、とのこと。 実際にそれを行うことで、この問題は解消することを確認した。


Tags: nuxtnuxt3

Related Articles