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

this.$nuxt is undefined in component in module #501

Open
dvdmlln opened this issue Apr 21, 2021 · 0 comments
Open

this.$nuxt is undefined in component in module #501

dvdmlln opened this issue Apr 21, 2021 · 0 comments

Comments

@dvdmlln
Copy link

dvdmlln commented Apr 21, 2021

Describe the bug
When creating a component within a module, this.$nuxt is undefined in the component when using Options API (Vue.extend) or Class API (@component). Defining the component using export default {...} everything works as expected.

To Reproduce
Steps to reproduce the behavior:

  1. Create a module with a component
  2. Use TypeScript for component with Options API or Class API
  3. Try to access this.$nuxt -> undefined

EDIT:
Problem occurs only when Module is in a local package outside the project folder.

With this folder structure, TestComponent.vue cannot use Options or Class API:

├── Test-Module/
│   └── components/
│       └── TestComponent.vue
└── Nuxt-Project/
    └── nuxt.config.js

This on the other hand works:

└── Nuxt-Project/
    ├── modules/
    │   └── Test-Module/
    │       └── components/
    │           └── TestComponent.vue
    └── nuxt.config.js

When I use npm pack and then install the tgz as a dependency in the nuxt project it works as well.

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

1 participant