Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@vuepress/plugin-search: Uncaught (in promise) Error: useRouteLocale() is called without provider. #3040

Open
1 task
jchalex opened this issue May 7, 2022 · 9 comments

Comments

@jchalex
Copy link

jchalex commented May 7, 2022

  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

module.exports = {
...
plugins: [
    backToTopPlugin(),
    mediumZoomPlugin({}),
    nprogressPlugin(),
    searchPlugin({}),
  ],
  ...
};

And the whole page is empty, which can not loading correct.

What is expected?

Expecting a search box in the navigation, page loading correct.

What is actually happening?

image

image

Other relevant information

"devDependencies": {
    "@vuepress/bundler-vite": "^2.0.0-beta.41",
    "@vuepress/plugin-back-to-top": "^2.0.0-beta.41",
    "@vuepress/plugin-docsearch": "^2.0.0-beta.41",
    "@vuepress/plugin-medium-zoom": "^2.0.0-beta.41",
    "@vuepress/plugin-nprogress": "^2.0.0-beta.41",
    "@vuepress/plugin-register-components": "^2.0.0-beta.43",
    "@vuepress/plugin-search": "^2.0.0-beta.43",
    "@vuepress/theme-default": "^2.0.0-beta.41",
    "vuepress": "^2.0.0-beta.41"
  }
  • Output of npx vuepress info in my VuePress project:
System:
    OS: macOS 11.4
    CPU: (8) x64 Apple M1
    Memory: 22.80 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 8.4.1 - /usr/local/bin/npm
  Utilities:
    Git: 2.30.1 - /usr/bin/git
  Browsers:
    Chrome: 101.0.4951.54
    Edge: Not Found
    Firefox: 92.0
    Safari: 14.1.1
  npmPackages:
    @vuepress/bundler-vite: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli:  2.0.0-beta.41 
    @vuepress/client:  2.0.0-beta.41 (2.0.0-beta.43)
    @vuepress/core:  2.0.0-beta.41 (2.0.0-beta.43)
    @vuepress/markdown:  2.0.0-beta.41 (2.0.0-beta.43)
    @vuepress/plugin-active-header-links:  2.0.0-beta.41 
    @vuepress/plugin-back-to-top: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/plugin-container:  2.0.0-beta.41 
    @vuepress/plugin-docsearch: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/plugin-external-link-icon:  2.0.0-beta.41 
    @vuepress/plugin-git:  2.0.0-beta.41 
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/plugin-nprogress: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/plugin-palette:  2.0.0-beta.41 
    @vuepress/plugin-prismjs:  2.0.0-beta.41 
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: ^2.0.0-beta.43 => 2.0.0-beta.43 
    @vuepress/plugin-search: ^2.0.0-beta.43 => 2.0.0-beta.43 
    @vuepress/plugin-shiki: Not Found
    @vuepress/plugin-theme-data:  2.0.0-beta.41 
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.41 (2.0.0-beta.43)
    @vuepress/theme-default: ^2.0.0-beta.41 => 2.0.0-beta.41 
    @vuepress/utils:  2.0.0-beta.41 (2.0.0-beta.43)
    vue:  3.2.33 
    vue-loader: Not Found
    vue-router:  4.0.14 
    vuepress: ^2.0.0-beta.41 => 2.0.0-beta.41 
    vuepress-vite:  2.0.0-beta.41 
    vuepress-webpack: Not Found
@jchalex jchalex changed the title Uncaught (in promise) Error: useRouteLocale() is called without provider. @vuepress/plugin-search: Uncaught (in promise) Error: useRouteLocale() is called without provider. May 7, 2022
@boakenfull
Copy link

boakenfull commented May 27, 2022

I have the same problem here - with 2.0.0-beta.45

@straumat
Copy link

straumat commented May 30, 2022

Same here with ^2.0.0-beta.46

@icodea
Copy link

icodea commented May 31, 2022

Same here with ^2.0.0-beta.46

pnpm add vuepress@next-->
devDependencies:

  • vuepress 2.0.0-beta.45
  • vuepress 2.0.0-beta.46

mMuyLw

@icodea
Copy link

icodea commented May 31, 2022

i solve it in my project.

@vuepress/client 2.0.0-beta.46-->@vuepress/client 2.0.0-beta.45 .

❯ pnpm add -D @vuepress/client@2.0.0-beta.45
Packages: +2 -2
++--
Progress: resolved 659, reused 640, downloaded 0, added 0, done

devDependencies:
- @vuepress/client 2.0.0-beta.46
+ @vuepress/client 2.0.0-beta.45
- vuepress 2.0.0-beta.46
+ vuepress 2.0.0-beta.46

and It works successfully!

@litingyes
Copy link

when i development my vuepress-theme, i have the same error with using useRouteLocale in my Vue SFC, whether @vuepress/client 2.0.0-beta.45 or @vuepress/client 2.0.0-beta.46 with vuepress@2.0.0-beta.46

@icodea
Copy link

icodea commented Jun 7, 2022

Such errors are usually caused by incorrectly containing multiple versions of @vue/xxx, @vuepress/xxx, vue or vue-router in the project.Make sure you are using the latest vuepress and vuepress-plugins and theme versions

15Uj0k

@catlair
Copy link

catlair commented Jun 17, 2022

使用 @vuepress/plugin-docsearch@next 遇到同样的问题。

yarn upgrade-interactive makes it work.

@zwsnail
Copy link

zwsnail commented Jul 21, 2022

const { searchPlugin } = require('@vuepress/plugin-search')

module.exports = {
  plugins: [
    searchPlugin({
      // options
    }),
  ],
}

when it shows an error, just run
'npm update'
it works for me.

@WUTONK
Copy link

WUTONK commented Oct 23, 2022

I think the problem is that the vuepress version is incompatible with searchPlugin.

image
ts(6133)&ts(2307)

image

You need to install the same version of searchPlugin as vuepress to run normally.

And check whether there is such a statement. For me, it is generated automatically when I install it automatically, which will lead to incorrect mapping of pnpm to search plugin
image

"pnpm": "link:@vuepress/plugin-search"

The following code can be referred to:

Installation command
pnpm add -D @vuepress/plugin-search@2.0.0-beta.43

config.ts

plugins: [
    // @ts-ignore
    localeRedirectPlugin(),
    backToTopPlugin(),
    nprogressPlugin(),
    mediumZoomPlugin({
      delay: 50 //切换路由后开始生效的延迟时间
    }),
    searchPlugin({

      maxSuggestions : 7,
      //将首页排除出可搜索名单
      isSearchable: (page) => page.path !== '/',

      locales: {
        '/en/': {
          placeholder: 'Search',
        },
        '/zh/': {
          placeholder: '搜索',
        },
        '/jp/': {
          placeholder: '検索',
        },
      },
    }),
  ],

package.json

  `"devDependencies": {
    "@kecrily/eslint-config": "^0.1.3",
    "@vuepress/client": "^2.0.0-beta.43",
    "@vuepress/plugin-search": "2.0.0-beta.43",
    "eslint": "^8.15.0",
    "postcss": "^8.4.13",
    "typescript": "^4.6.4",
    "vue": "^3.2.33",
    "vuepress": "2.0.0-beta.43",
    "vuepress-plugin-locale-redirect": "^1.0.1"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants