Markus Ferringer
Markus Ferringer

Reputation: 111

After updating vscode-languageclient, my Visual Studio Code extension does not compile any more

I am developing a Visual Studio Code extension (languageserver), and it worked perfectly fine. However, in order to use the latest languageserver features, I updated the vscode-languageclient to the latest version V7.0.0

npm install vscode-languageclient

After removing both node_modules and out folders, and recompiling with

npm install
npm build
npm run compile

I get a TON of compile errors. To show just a few:

node_modules/vscode-languageclient/lib/common/callHierarchy.d.ts:1:75 - error TS2305: Module '"vscode"' has no exported member 'CallHierarchyItem'.
  1 import { Disposable, TextDocument, ProviderResult, Position as VPosition, CallHierarchyItem as VCallHierarchyItem [...]

node_modules/vscode-languageclient/lib/common/callHierarchy.d.ts:1:116 - error TS2305: Module '"vscode"' has no exported member 'CallHierarchyIncomingCall'.
  1 import { Disposable, TextDocument, ProviderResult, Position as VPosition, CallHierarchyItem as VCallHierarchyItem, CallHierarchyIncomingCall as VCallHierarchyIncomingCall [...]

I am sure that I an missing something important here, but I have no idea what. Btw, the behavior is the same on linux and windows. Maybe somebody had a similar issue or knows what I am doing wrong. Thanks in advance!

Upvotes: 3

Views: 3131

Answers (2)

Finkle MacGraw
Finkle MacGraw

Reputation: 110

Just a follow up answer as this problem seemingly occurs very often: as of version 7.0.0 of the vscode-languageclient package, the codebase was split into "common", "node" and "browser".

split code into common, node and browser to allow using the LSP client and server npm modules in a Web browser via webpack. This is a breaking change and might lead to compile / runtime errors if not adopted. Every module has now three different exports which represent the split into common, node and browser. Lets look at vscode-jsonrpc for an example: (a) the import vscode-jsonrpc will only import the common code, (b) the import vscode-jsonrpc\node will import the common and the node code and (c) the import vscode-jsonrpc\browser will import the common and browser code.

Source: https://github.com/microsoft/vscode-languageserver-node#3160-protocol-600-json-rpc-700-client-and-700-server

Outdated docs are still floating around and it might not be obvious that "npm install vscode-languageclient" will get you the latest version that does not match the old documentation.

Upvotes: 5

Markus Ferringer
Markus Ferringer

Reputation: 111

As usual, after asking the question I figured it out almost right away.

I did not delete the package-lock.json file. This was the reason for the ton of error messages. It lead to some kind of version mismatch / inconsistency in the code base. So deleting it before executing npm install fixed this issue.

Then, however, the src/extension.ts file with the async function activate() inside showed some errors. The solution here - besides minor follow-ups - is to change

import { LanguageClient, LanguageClientOptions, ...} from 'vscode-languageclient';

to

import { LanguageClient, LanguageClientOptions, ...} from 'vscode-languageclient/node';

Upvotes: 7

Related Questions