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

Throws error about multiple root elements in template. (Vue 3 + TypeScript) #2299

Closed
dannysmc95 opened this issue Sep 21, 2020 · 8 comments
Closed

Comments

@dannysmc95
Copy link

  • [ x ] I have searched through existing issues
  • [ x ] I have read through docs
  • [ x ] I have read FAQ

Info

  • Platform: Ubuntu 20.04 (WSL2 and Ubuntu 20.04)
  • Vetur version: 0.27.3
  • VS Code version: 1.49.1

Problem

When adding multiple root template elements within a SFC (.vue file), Vetur throws an error, even though Vue 3 now supports it, see screenshot below:

Screenshot

Reproducible Case

NOTE: Repo is used for another issue in this project as well.

  1. Clone the repo: https://github.com/dannysmc95/vetur-issue1,
  2. Install dependencies, using npm install,
  3. Navigate to the ./src/App.vue file in VSCode and see the issue,
@octref
Copy link
Member

octref commented Sep 21, 2020

I cannot reproduce from https://github.com/dannysmc95/vetur-issue1
Vetur uses package.json's vue dependency version to figure out if you are using Vue 3. If your package.json is not at root folder (maybe it's in budee-ui) this will fail back to Vue 2.

If you don't want this you can turn off the default linting and configure your own: https://vuejs.github.io/vetur/linting-error.html

@dannysmc95
Copy link
Author

Sure, I have checked the issue, it seems to occur when multiple folders are included in the same workspace...?

@octref
Copy link
Member

octref commented Sep 21, 2020

There's no multiroot support yet: #424

@duck-dev-go
Copy link

duck-dev-go commented Nov 18, 2020

I am experiencing the same problem when having multiple folders in a workspace within VS Code

@duck-dev-go
Copy link

Turning off Vetur linting resolved the problem in my case

https://stackoverflow.com/questions/64867504/vue-3-the-template-root-requires-exactly-one-element-eslint-plugin-vue

@yoyo930021
Copy link
Member

If you have this problem, your package json isn't in opened project root.
Causes vetur to infer the vue version incorrectly.

  1. If you have eslint in project, you can disable template validation temporarily.
  2. Move package.json in opened project root,
    This is the best solution, because vue version also use other feature.
    If you can't move this file, you can wait for Vetur config file RFC #2378 .

@mikerockett
Copy link

If you have a simple client+server workspace, where client is your Vue app, make sure it's the first project in the workspace. Vetur seems to pick it up. Naturally, any other Vue projects in the same workspace won't be picked up yet.

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

No branches or pull requests

6 participants