vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 923 forks source link

[Bug report] TypeError: Cannot read properties of undefined (reading 'colorMode') #1028

Closed YconquestY closed 1 year ago

YconquestY commented 1 year ago

Description

I use the default theme and a KaTeX plugin. After installing the dependencies, errors occur when running npm run docs:build. The problem is reproduced here, and a brief log is below:

> blog@0.1.0 docs:build
> vuepress build docs

info Initializing VuePress and preparing data...
⠇ Compiling with vite
(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✔ Compiling with vite - done
⠋ Rendering pages⠋ Rendering pages /TypeError: Cannot read properties of undefined (reading 'value')
    at ReactiveEffect.fn (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1217:101)
    at ReactiveEffect.run (/home/will/blog/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js:178:25)
    at ComputedRefImpl.get value [as value] (/home/will/blog/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js:1066:39)
    at setupDarkMode (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1538:76)
    at Object.setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1718:5)
    at setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1954:59)
    at callWithErrorHandling (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:119:22)
    at setupStatefulComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5789:29)
    at setupComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5770:11)
    at renderComponentVNode (/home/will/blog/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:169:17)
[Vue warn]: Component VuepressApp is missing template or render function.
⠙ Rendering pagesTypeError: Cannot read properties of undefined (reading 'colorMode')
    at setupDarkMode (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1538:82)
    at Object.setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1718:5)
    at setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1954:59)
    at callWithErrorHandling (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:119:22)
    at setupStatefulComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5789:29)
    at setupComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5770:11)
    at renderComponentVNode (/home/will/blog/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:169:17)
    at renderToString (/home/will/blog/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:443:26)
    at renderPage (/home/will/blog/node_modules/@vuepress/bundler-vite/lib/build/renderPage.js:21:32)
    at async /home/will/blog/node_modules/@vuepress/bundler-vite/lib/build/build.js:54:13
[Vue warn]: Component VuepressApp is missing template or render function.
TypeError: Cannot read properties of undefined (reading 'colorMode')
    at setupDarkMode (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1538:82)
    at Object.setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1718:5)
    at setup (/home/will/blog/docs/.vuepress/.temp/.server/app.js:1954:59)
    at callWithErrorHandling (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:119:22)
    at setupStatefulComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5789:29)
    at setupComponent (/home/will/blog/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js:5770:11)
    at renderComponentVNode (/home/will/blog/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:169:17)
    at renderToString (/home/will/blog/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js:443:26)
    at renderPage (/home/will/blog/node_modules/@vuepress/bundler-vite/lib/build/renderPage.js:21:32)
    at async /home/will/blog/node_modules/@vuepress/bundler-vite/lib/build/build.js:54:13
[Vue warn]: Component VuepressApp is missing template or render function.
…
…
…
…

Reproduction

https://stackblitz.com/edit/vuepress-scrkty

Used Package Manager

npm

System Info

System:
    OS: Linux 5.13 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (1) x64 Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz
    Memory: 329.54 MB / 908.48 MB
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.16.0 - /usr/bin/node
    Yarn: Not Found
    npm: 8.11.0 - /usr/bin/npm
  Utilities:
    Git: 2.25.1 - /usr/bin/git
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @vuepress/bundler-vite: Not Found
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli: Not Found
    @vuepress/client: Not Found
    @vuepress/core: Not Found
    @vuepress/markdown: Not Found
    @vuepress/plugin-active-header-links: Not Found
    @vuepress/plugin-back-to-top: Not Found
    @vuepress/plugin-container: Not Found
    @vuepress/plugin-docsearch: Not Found
    @vuepress/plugin-external-link-icon: Not Found
    @vuepress/plugin-git: Not Found
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom: Not Found
    @vuepress/plugin-nprogress: Not Found
    @vuepress/plugin-palette: Not Found
    @vuepress/plugin-prismjs: Not Found
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: Not Found
    @vuepress/plugin-search: Not Found
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data: Not Found
    @vuepress/plugin-toc: Not Found
    @vuepress/shared: Not Found
    @vuepress/theme-default: Not Found
    @vuepress/utils: Not Found
    vue: Not Found
    vue-loader: Not Found
    vue-router: Not Found
    vuepress: Not Found
    vuepress-vite: Not Found
    vuepress-webpack: Not Found
Mister-Hope commented 1 year ago

Provide a minimal reproduction by opening an new issue plz. You are definitely not providing a minimal production, and no one has any insterest digging in to thousands of lines.

github-actions[bot] commented 1 year ago

Hello @YconquestY. Please provide a minimal reproduction using a GitHub repository or v2.vuepress.vuejs.org/new. Issues marked with need reproduction will be closed if they have no activity within 3 days.

bd82 commented 1 year ago

I just encountered this issue and it was resolved after I re-built my pnpm-lock.yaml file.

hustcer commented 1 year ago

I got the same issue when upgrade from 2.0.0-beta.48 to 2.0.0-beta.50, still no luck yet

hustcer commented 1 year ago

Seems caused by https://github.com/vuepress/vuepress-next/blob/d283ffe3ef0668bfea54e6d973066695f46f13c0/ecosystem/plugin-theme-data/src/client/config.ts#L17 Why routeLocale is undefined?

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'value')
    at ReactiveEffect.fn (config.js:10:100)
    at ReactiveEffect.run (reactivity.esm-bundler.js:185:25)
    at get value [as value] (reactivity.esm-bundler.js:1144:39)
    at setupDarkMode (useDarkMode.js:21:73)
    at Object.setup (config.js:35:9)
    at setup (app.js?v=6ec5f7fd:249:29)
    at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
    at setupStatefulComponent (runtime-core.esm-bundler.js:7165:29)
    at setupComponent (runtime-core.esm-bundler.js:7120:11)
    at mountComponent (runtime-core.esm-bundler.js:5473:13)
liawnliu commented 1 year ago

Seems caused by

https://github.com/vuepress/vuepress-next/blob/d283ffe3ef0668bfea54e6d973066695f46f13c0/ecosystem/plugin-theme-data/src/client/config.ts#L17

Why routeLocale is undefined?

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'value')
    at ReactiveEffect.fn (config.js:10:100)
    at ReactiveEffect.run (reactivity.esm-bundler.js:185:25)
    at get value [as value] (reactivity.esm-bundler.js:1144:39)
    at setupDarkMode (useDarkMode.js:21:73)
    at Object.setup (config.js:35:9)
    at setup (app.js?v=6ec5f7fd:249:29)
    at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
    at setupStatefulComponent (runtime-core.esm-bundler.js:7165:29)
    at setupComponent (runtime-core.esm-bundler.js:7120:11)
    at mountComponent (runtime-core.esm-bundler.js:5473:13)

Have you resolved it?