Repository navigation
usePageHead() is called without provider #103
|
Hi, Vuepress fam! I'm seeing this error I'm using the node API from inside an internal CLI tool which among other things it builds docs using vuepress, the tool is packaged and distributed through NPM. After I publish the package and try running it, It fails with the error. Weirdly when I use {
version: '2.0.0-beta.6',
options: {
base: '/cli/',
lang: 'en-US',
title: 'CLI Documentation',
description: "Documentation for CLI",
head: [],
locales: {},
theme: '@vuepress/default',
themeConfig: { sidebarDepth: 2, sidebar: 'auto' },
bundler: '@vuepress/vite',
bundlerConfig: {},
source: '/Users/**/Work/test-project/docs',
dest: '/Users/**/Work/test-project/docs/.vuepress/dist',
temp: '/Users/**/Work/test-project/docs/.vuepress/.temp',
cache: '/Users/**/Work/test-project/docs/.vuepress/.cache',
public: '/Users/**/Work/test-project/docs/.vuepress/public',
markdown: {},
debug: false,
host: '0.0.0.0',
port: 8080,
open: false,
evergreen: true,
pagePatterns: [ '**/*.md', '!.vuepress', '!node_modules' ],
templateDev: '/Users/**/.nvm/versions/node/v12.18.4/lib/node_modules/cli-package/node_modules/@vuepress/client/templates/index.dev.html',
templateSSR: '/Users/**/.nvm/versions/node/v12.18.4/lib/node_modules/cli-package/node_modules/@vuepress/client/templates/index.ssr.html',
shouldPreload: true,
shouldPrefetch: false
},
dir: {
cache: [Function],
temp: [Function],
source: [Function],
dest: [Function],
client: [Function],
public: [Function]
},
env: {
isProd: false,
isTest: false,
isDev: false,
isDebug: false,
nodeEnv: undefined
},
siteData: {
base: '/cli/',
lang: 'en-US',
title: 'CLI Documentation',
description: "Documentation for CLI",
head: [],
locales: {}
},
markdown: MarkdownIt {
inline: ParserInline { ruler: [Ruler], ruler2: [Ruler] },
block: ParserBlock { ruler: [Ruler] },
core: Core { ruler: [Ruler] },
renderer: Renderer { rules: [Object] },
linkify: LinkifyIt {
__opts__: [Object],
__index__: -1,
__last_index__: -1,
__schema__: '',
__text_cache__: '',
__schemas__: [Object],
__compiled__: [Object],
__tlds__: [Array],
__tlds_replaced__: false,
re: [Object]
},
validateLink: [Function: validateLink],
normalizeLink: [Function: normalizeLink],
normalizeLinkText: [Function: normalizeLinkText],
utils: {
lib: [Object],
assign: [Function: assign],
isString: [Function: isString],
has: [Function: has],
unescapeMd: [Function: unescapeMd],
unescapeAll: [Function: unescapeAll],
isValidEntityCode: [Function: isValidEntityCode],
fromCodePoint: [Function: fromCodePoint],
escapeHtml: [Function: escapeHtml],
arrayReplaceAt: [Function: arrayReplaceAt],
isSpace: [Function: isSpace],
isWhiteSpace: [Function: isWhiteSpace],
isMdAsciiPunct: [Function: isMdAsciiPunct],
isPunctChar: [Function: isPunctChar],
escapeRE: [Function: escapeRE],
normalizeReference: [Function: normalizeReference]
},
helpers: {
parseLinkLabel: [Function: parseLinkLabel],
parseLinkDestination: [Function: parseLinkDestination],
parseLinkTitle: [Function: parseLinkTitle]
},
options: {
html: true,
xhtmlOut: false,
breaks: false,
langPrefix: 'language-',
linkify: false,
typographer: false,
quotes: '“”‘’',
highlight: null,
maxNesting: 100
},
render: [Function]
},
pluginApi: {
plugins: [],
hooks: {
onInitialized: [Object],
onPrepared: [Object],
onWatched: [Object],
onGenerated: [Object],
extendsPageOptions: [Object],
extendsPageData: [Object],
extendsMarkdown: [Object],
clientAppEnhanceFiles: [Object],
clientAppRootComponentFiles: [Object],
clientAppSetupFiles: [Object],
alias: [Object],
define: [Object]
},
registerHooks: [Function]
},
use: [Function: use],
useByConfig: [Function: useByConfig],
init: [Function: init],
prepare: [Function: prepare],
dev: [Function: dev],
build: [Function: build]
} |
Replies: 10 comments 8 replies
|
You'd better provide a reproduce repo. This sounds to be caused by vite's pre-bundling feature. Some packages might be pre-bundled unexpectly. |
|
I should have added that this happens during the "Rendering pages" stage. It compiles fine.
|
|
Another piece of info is that when I run the package (cli) inside the project itself it runs with no issues, the problem only happens when I run it on other projects. This is what that method to build the docs looks like: import path from 'path'
import fs from 'fs-extra'
process.env.NODE_ENV = 'production'
const TEMP_LOCATION = path.resolve('.temp')
const buildDocs = async (space: string, docsLoc = 'docs') => {
/**
* Create the temporary directory and copy docs to it
*/
await fs.ensureDir(TEMP_LOCATION)
await fs.copy(`${docsLoc}/.`, TEMP_LOCATION)
/**
* Create and build the app from the docs in the temp directory
*/
const app = createApp({
source: TEMP_LOCATION,
bundler: '@vuepress/vite',
base: `/${space}/`,
title: `${capitalize(space)} Documentation`,
themeConfig: { sidebarDepth: 2, sidebar: 'auto' },
description: `Documentation for ${capitalize(space)} space`
})
await app.init()
await app.prepare()
return app.build()
} |
|
@meteorlxy I was able to extract the vuepress portion from our cli and create a reproduction repo, could you please take a quick peek at the problem? To reproduce, using node Step 1: Clone repo Step 2: Change into repo Step 3: Install deps and build the project Step 4: Link CLI locally Step 5: Create a target project Step 6: Run linked CLI on target project At this point Vuepress will build successfully but during the render stage you should see the following error: However, if you enter the I really appreciate the help and I'm sorry to continue pressing on this issue but I have spent countless hours trying to figure out the root cause of the problem without success. So any insight into this issue is highly appreciated. |
|
I'm also encountering this error, I'm developing a nx plugin integration with VuePress, which means I'm using programmatic API export from VuePress instead of VuePress CLI, just like: And when invoking this, I got same errors above.
|
|
This seems to still be an issue. I tried using a git submodule in my project to get the latest features because the latest beta is too outdated for me and none of the ways I linked them together appear to work, it always fails with the same error: This is not the only thing I've tried but one state that doesn't work can be seen here: https://github.com/Joelius300/werewolf-guide/tree/use-vuepress-from-source |
|
Any progress on this one, is it still existing with latest vuepress, vite, webpack and vue? |
|
Still seeing this now on |
|
Is there any solution to this? I'm experiencing this issue with |
|
maybe it can help
https://vuepress-theme-hope.github.io/v2/faq/common-error.html#usexxx-is-called-without-provider |
maybe it can help
https://vuepress-theme-hope.github.io/v2/faq/common-error.html#usexxx-is-called-without-provider