question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: ReferenceError: window is not defined

See original GitHub issue

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

1.4.1

What browser are you using?

Chrome

Reproduction repository

https://github.com/productdevbook/nuxt3-app/tree/dev

Describe your issue

yarn build yarn start localhost:3000 click menus, and take a look around the site

Logs

[Vue warn]: Component Menu  is missing template or render function.
ReferenceError: window is not defined

[Vue warn]: Component Menu  is missing template or render function.
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
[Vue warn]: onUnmounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
[Vue warn]: onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.
[Vue warn]: provide() can only be used inside setup().
[Vue warn]: provide() can only be used inside setup().
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: inject() can only be used inside setup() or functional components.
TypeError: Cannot read property 'show' of undefined

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
RobinMalfaitcommented, Oct 21, 2021

This should be fixed (#867), and will be available in the next release. You can already try it using npm install @headlessui/vue@dev or yarn add @headlessui/vue@dev.

2reactions
RobinMalfaitcommented, Oct 21, 2021

I didn’t have time to look into that one yet, but we do have ESM builds as well, which is also configured in the package.json. Don’t want to jump to conclusions here, but maybe Nuxt is not resolving the correct file to use.

E.g.: https://unpkg.com/browse/@headlessui/vue@1.4.1/dist/headlessui.esm.js There is also no require defined in that file, so should be fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

referenceerror: window is not defined, how to solve
Here's how to fix the “referenceerror: window is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >
How To Solve ReferenceError window is not defined in ...
Fixing a window is not defined error can be quite simple. In most cases, all you will need to do is wrap your...
Read more >
How to solve "window is not defined" errors in React and Next.js
1. First solution: typeof · 2. Second solution: the useEffect hook · 3. Third solution: dynamic loading.
Read more >
[Solved] ReferenceError : window is not defined - ItsJavaScript
The ReferenceError : window is not defined error mainly occurs if you are using the window object in Node.js, React.js, Next.js.
Read more >
How to solve Next.js window is not defined
ReferenceError : window is not defined is a pretty common error you may run into when using Next.js for the first time but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found