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

[Nuxt] document not found #1100

Open
Denoder opened this issue Mar 10, 2023 · 4 comments
Open

[Nuxt] document not found #1100

Denoder opened this issue Mar 10, 2023 · 4 comments

Comments

@Denoder
Copy link

Denoder commented Mar 10, 2023

When running naive-ui with inline-theme-disabled an error occurs:

[Vue warn]: Unhandled error during execution of render function 
  at <Layout class="w-full h-screen" has-sider="" >
[nuxt] error caught during app initialization ReferenceError: document is not defined
    at queryElement (/home/ubuntu/main/.output/server/node_modules/css-render/lib/utils.js:17:5)
    at mount (/home/ubuntu/main/.output/server/node_modules/css-render/lib/mount.js:59:52)
    at Object.wrappedMount [as mount] (/home/ubuntu/main/.output/server/node_modules/css-render/lib/c.js:14:45)
    at renderCallback (file:///home/ubuntu/main/.nuxt/dist/server/_nuxt/use-css-vars-class-5be16d4a.js:35:38)
    at Proxy.onRender (file:///home/ubuntu/main/.nuxt/dist/server/_nuxt/use-css-vars-class-5be16d4a.js:48:71)
    at Proxy.render (file:///home/ubuntu/main/.nuxt/dist/server/_nuxt/Layout-5a99573f.js:122:68)
    at renderComponentRoot (/home/ubuntu/main/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:906:44)
    at renderComponentSubTree (/home/ubuntu/main/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:719:51)
    at renderComponentVNode (/home/ubuntu/main/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:644:16)
    at ssrRenderComponent (/home/ubuntu/main/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:94:12) {
  statusCode: 500,
  fatal: false,
  unhandled: false,
  statusMessage: undefined,
  __nuxt_error: true
}

the lines in question are:

const queriedTarget = queryElement(id)

and
export function queryElement (id: string): HTMLStyleElement | null {

this is only specific to Nuxt when running inline-theme-disabled with naive

@peterroe
Copy link

same problem...

@peterroe
Copy link

Solve:

<ClientOnly>
	// ...
</ClientOnly>

@Denoder
Copy link
Author

Denoder commented Apr 16, 2023

Solve:

<ClientOnly>
	// ...
</ClientOnly>

This would conflict withe pages that use ssr, and are slotted under a layout cause this is happening to most of the components and the layouts.

@peterroe
Copy link

Do you hava a good way to solve it?👀

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

2 participants