VuePress2で「Cannot read properties of undefined (reading ‘value’)」

問題

以下のようにVuePress2で build を行うと「Cannot read properties of undefined (reading ‘value’)」のエラーが発生した。

PS C:\Code\******\website_html_form2> npm run docs:build
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> website_html_form2@1.0.0 docs:build
> vuepress build docs

warning [@vuepress/plugin-container] type option is required
warning plugin @vuepress/plugin-back-to-top has been used multiple times, only the last one will take effect
warning plugin @vuepress/plugin-external-link-icon has been used multiple times, only the last one will take effect
warning plugin @vuepress/plugin-medium-zoom has been used multiple times, only the last one will take effect
warning plugin @vuepress/plugin-nprogress has been used multiple times, only the last one will take effect
warning plugin @vuepress/plugin-prismjs has been used multiple times, only the last one will take effect
✔ Initializing and preparing data - done in 563ms
✔ Compiling with vite - done in 8.89s
⠙ Rendering 4 pages[Vue warn]: Unhandled error during execution of setup function 
  at <VuepressApp>
✖ Rendering 4 pages - failed in 197ms
TypeError: Cannot read properties of undefined (reading 'value')
    at ReactiveEffect.fn (file:///C:/Code/******/website_html_form2/docs/.vuepress/.temp/.server/app.c3841867.mjs:540:97)
    at ReactiveEffect.run (C:\Code\******\website_html_form2\node_modules\@vue\reactivity\dist\reactivity.cjs.js:182:19)
    at ComputedRefImpl.get value [as value] (C:\Code\******\website_html_form2\node_modules\@vue\reactivity\dist\reactivity.cjs.js:1143:33)
    at setupDarkMode (file:///C:/Code/******/website_html_form2/docs/.vuepress/.temp/.server/app.c3841867.mjs:904:71)
    at Object.setup (file:///C:/Code/******/website_html_form2/docs/.vuepress/.temp/.server/app.c3841867.mjs:2582:5)
    at setup (file:///C:/Code/******/website_html_form2/docs/.vuepress/.temp/.server/app.c3841867.mjs:3867:59)
    at callWithErrorHandling (C:\Code\******\website_html_form2\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:156:18)
    at setupStatefulComponent (C:\Code\******\website_html_form2\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:7190:25)
    at setupComponent (C:\Code\******\website_html_form2\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:7151:36)
    at renderComponentVNode (C:\Code\******\website_html_form2\node_modules\@vue\server-renderer\dist\server-renderer.cjs.prod.js:354:15)
PS C:\Code\******\website_html_form2>             
PS C:\Code\ichisan-form-web\website_html_form2>             

原因・対策

VuePress2 のパッケージがが dependencies にあったことが原因。
devDependencies に移動させることで修復できた。(なぜかGithub Actions でのデプロイでは実行できていたのは謎)

Before

  "dependencies": {
    "@snippetors/vuepress-plugin-code-copy": "^1.2.3",
    "@vuepress/plugin-container": "^2.0.0-beta.66",
    "@vuepress/plugin-external-link-icon": "^2.0.0-beta.66",
    "@vuepress/plugin-google-analytics": "^2.0.0-beta.66",
    "@vuepress/plugin-medium-zoom": "^2.0.0-beta.66",
    "@vuepress/plugin-nprogress": "^2.0.0-beta.66",
    "@vuepress/plugin-register-components": "^2.0.0-beta.66",
    "vuepress-plugin-code-copy": "^1.0.6"
    "vuepress": "^2.0.0-beta.66",
  },
  "devDependencies": {
    "vuepress-plugin-sitemap2": "^2.0.0-beta.233"
  }
}

After

  "dependencies": {
    "@snippetors/vuepress-plugin-code-copy": "^1.2.3",
    "@vuepress/plugin-container": "^2.0.0-beta.66",
    "@vuepress/plugin-external-link-icon": "^2.0.0-beta.66",
    "@vuepress/plugin-google-analytics": "^2.0.0-beta.66",
    "@vuepress/plugin-medium-zoom": "^2.0.0-beta.66",
    "@vuepress/plugin-nprogress": "^2.0.0-beta.66",
    "@vuepress/plugin-register-components": "^2.0.0-beta.66",
    "vuepress-plugin-code-copy": "^1.0.6"
  },
  "devDependencies": {
    "vuepress": "^2.0.0-beta.66",
    "vuepress-plugin-sitemap2": "^2.0.0-beta.233"
  }
}

以上。

コメント

タイトルとURLをコピーしました