volarjs/volar.js

Volar fails to start in eclipse theia

mind-ar opened this issue · 2 comments

Volar fails to start in eclipse theia because cant find typescript module:

Message: Request initialize failed with message: Can't find typescript.js or tsserverlibrary.js in

after some investigation, i found that volar is trying to load the typescript module from extensions/node_modules, that seems to be the place where vscode contains this module.

if (vscode.env.appRoot) {
const libPath = path.join(
vscode.env.appRoot.replace(/\\/g, '/'),
'extensions/node_modules/typescript/lib',
);
return {
path: libPath,
version: await getTsVersion(libPath),
isWeb: false,
};
}

there's a workaround, installing the ms-vscode.vscode-typescript-next extensions, that uses extensionPath to find the node_modules folder (i think that extensionPath is empty so it use the node_modules from de theia folder)

const nightly = vscode.extensions.getExtension('ms-vscode.vscode-typescript-next');
if (nightly) {
const libPath = path.join(
nightly.extensionPath.replace(/\\/g, '/'),
'node_modules/typescript/lib',
);
return {
path: libPath,
version: await getTsVersion(libPath),
isWeb: false,
};
}

here's the related issue in theia repo: eclipse-theia/theia#12443

is there any chance to add a fix to this problem (ie, validating that the extensions/node_modules exists)?

Thanks

Volar needs to be able to load TypeScript. Does Theia provide this in some other way?

Note that crash happens in a fallback mechanism. Typically users set the typescript.tsdk option in their VS Code settings.

@remcohaszing Theia project lead here. Since adopters can use any set of vscode extensions they like, there is no guarantee that a Theia app ships with a TypeScript distribution. IMO the best fix would be to just specify in the error that the typescript.tsdk needs to be set in the project settings.