vuepress / core

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

[Bug report] Error: usePageFrontmatter () is called without provider. #1432

Closed recoluan closed 7 months ago

recoluan commented 7 months ago

Description

When I bump the vuepress dependencies of the custom theme to 2.0.0-rc.0 from 2.0.0-beta.67 , I reported the error "chunk-DHNSDB55.js?v=dbacff81:43 Uncaught (in promise) Error: usePageFrontmatter () is called without provider."

image

Reproduction

https://github.com/vuepress-reco/vuepress-theme-reco/tree/feature/bump-dependencies-to-2.0.0-rc.0

Used Package Manager

pnpm

System Info

System:
    OS: macOS 14.1.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 468.98 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.9.0 - ~/.nvm/versions/node/v18.9.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.7.1 - ~/.nvm/versions/node/v18.9.0/bin/npm
  Utilities:
    Git: 2.36.1 - /opt/homebrew/bin/git
  Browsers:
    Chrome: Not Found
    Edge: Not Found
    Safari: 17.1
  npmPackages:
    @vuepress/bundler-vite: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/bundler-webpack: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/cli: Not Found
    @vuepress/client: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/core: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/markdown: Not Found
    @vuepress/plugin-active-header-links: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-back-to-top: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-container: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-docsearch: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-external-link-icon: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-git: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-nprogress: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-palette: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-prismjs: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-search: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/plugin-toc: Not Found
    @vuepress/shared: 2.0.0-rc.0 => 2.0.0-rc.0 
    @vuepress/theme-default: Not Found
    @vuepress/utils: 2.0.0-rc.0 => 2.0.0-rc.0 
    vue: ^3.3.4 => 3.3.8 
    vue-loader: Not Found
    vue-router: ^4.2.5 => 4.2.5 
    vuepress: Not Found
    vuepress-vite: Not Found
    vuepress-webpack: Not Found
ntnyq commented 7 months ago

https://github.com/vuepress/vuepress-next/issues/885

meteorlxy commented 7 months ago

image

It seems that you have two different copies in your node_modules with different typescript version. Please consider:

recoluan commented 7 months ago

After I upgraded the version of 'typescript', I reported the following exception:

image
recoluan commented 7 months ago

After I upgraded the version of 'typescript', I reported the following exception:

image

I found that this error occurs in plugin only, so I implemented useThemeLocaleData in plugin to solve this problem, but I don't know if there is any other good way. Similar issue in the past have been for a long time and have no reference value.

image

Mister-Hope commented 7 months ago

I believed this is also because of multiple package instances in your repo. Double check that. At least we have no issues in vuepress-theme-hope repo, which probably has 3x lines comparing to your repo and also with a lot of plugins.

It also use plugin-theme-data and calls useThemeLocaleData, but works well.