vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.79k stars 390 forks source link

can not start language-server cause `TypeError: server.watchFiles is not a function` #4707

Closed CSNight closed 1 month ago

CSNight commented 1 month ago

Vue - Official extension or vue-tsc version

2.0.24~2.0.29

VSCode version

webstorm 2024.2

Vue version

3.4.35

TypeScript version

5.5.4

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 5.95 GB / 15.73 GB
  Binaries:
    Node: 20.13.1 - D:\Libaray\NodeJs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.5.2 - D:\Libaray\NodeJs\npm.CMD
    pnpm: 8.7.1 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Chrome: 116.0.5845.141
    Edge: Chromium (126.0.2592.113)
    Internet Explorer: 11.0.19041.4355

Steps to reproduce

npm i @vue/language-server and start it cause error

~\AppData\Roaming\npm\node_modules\@vue\language-server\lib\initialize.js:48
            fileWatcher = server.watchFiles(['**/*.{' + [...watchingExtensions].join(',') + '}']);
                                 ^

TypeError: server.watchFiles is not a function
    at updateFileWatcher (C:\Users\chens\AppData\Roaming\npm\node_modules\
@vue
\language-server\lib\initialize.js:48:34)
    at C:\Users\chens\AppData\Roaming\npm\node_modules\
...

What is expected?

after check the package i installed , i found that the error cause code line should be write like

 fileWatcher = server.fileWatcher.watchFiles(['**/*.{' + [...watchingExtensions].join(',') + '}']);

is there any wrong when build release?

What is actually happening?

the server can not start

Link to minimal reproduction

No response

Any additional comments?

No response

johnsoncodehk commented 1 month ago

This is caused by upgrading @vue/language-server 2.4.0-alpha.18 to 2.4.0-alpha.19 in node_modules. Can you confirm that upgrading to 2.4.0-alpha.20 can solve it?

CSNight commented 1 month ago

upgrade to 2.4.0-alpha.20 can solve it

pwang2 commented 1 month ago

@CSNight , thanks for the information. I have been frustrated for a while in neovim lsp and have been doubt the hybridMode setup from here Your workaround worked. basically, I have to edit the $HOME/.local/share/nvim/mason/packages/vue-language-server/node_modules/@vue/language-server/package.json as below.

image

pwang2 commented 1 month ago

The workaround fix is reinstalling mason installed version with a dependency override. if you reinstall, the override will be flushed. We don't have to be obsessed here to keep everything up to date. New vue-language-server version should be able to fix this.

vrubezhny commented 1 month ago

Any plans to release 2.1.0 or any intermediate version containing the fix for this issue?