Vetur error 2300 Duplicate identifier '(Missing)'

1.2k Views Asked by At

I'm having this weird error with Vetur in a typescript nuxt.js application. It shows this error message on the first line of all the components whether it's an empty line or has the tag.

I'm not sure when this error started to appear or what does it even mean?

Duplicate identifier '(Missing)'

Any help will be appreciated, thanks a lot!

4

There are 4 best solutions below

0
Omar Abdo On BEST ANSWER

So it turned out that this was because of Vetur experimental templateInterpolationService property. By turning it to false in the vetur.config.js file:

module.exports = {
  settings: {
    /* .. */
    'vetur.experimental.templateInterpolationService': false
    /* .. */
  }
};

Vetur stopped the unexpected interference with my components.

3
Robert On

The accepted answer is like chopping your arm off when your finger hurts! If you disable templateInterpolationService you lose a big part of the value of Vetur.

For me Vetur v0.35.0 broke when I upgraded typescript > 4.4

You can check which version(s) of typescript you're using by typing npm ls typescript in your project root.

If you're running typescript 4.4.4 (or lower), try this:

Restart Vue Lanaguage Server (in VSCode):
View ->
   Command Palette.. ->
      Vetur:Restart VLS (Vue Language Server)

If you're running typescript 4.5 or higher, you will probably run into this error. Still working to find a fix in this case.

Alternatively, to force your environment to use an older version of typescript across the board, you can ensure your version of npm is 8.3+ and use the new "overrides" section of package.json:

...
  "overrides": {
    "typescript": "4.4.4"
  },
...
0
Chaos Lee On

Making sure the gloabal ts version of vscode <=4.4.4. It may be some dependences(like @microsoft/api-extractor) using a newer typescript .

Creating vetur.config.js. Setting "vetur.useWorkspaceDependencies": "false" in settings. example:

module.exports = {
    settings: {
        "vetur.useWorkspaceDependencies": false,
        "vetur.experimental.templateInterpolationService": true
    }
}

Checking vscode OUTPUT panel in Vue Language Server, may:

[INFO ] Find node_modules paths in xxxxxxx - 247ms
[INFO ] Loaded bundled [email protected].
[INFO ] Loaded bundled prettier.
[INFO ] Loaded bundled @starptech/prettyhtml.
[INFO ] Loaded bundled prettier-eslint.
[INFO ] Loaded bundled prettier-tslint.
[INFO ] Loaded bundled stylus-supremacy.
[INFO ] Loaded bundled @prettier/plugin-pug.

Success!

0
Klesun On

It was fixed in vetur v0.36.0

Fix template type-checking when typescript >= 4.5. #3323,#3424.

It's not on vscode store yet, but you can download the vetur-0.36.0.vsix directly from github release and install manually:

enter image description here