From 87e09cfb188fdcbd0683a48a7d49983b51acd25a Mon Sep 17 00:00:00 2001 From: chemzqm Date: Thu, 27 Jun 2019 14:28:21 +0800 Subject: [PATCH] cache error on require typescript module --- src/server/utils/versionProvider.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/utils/versionProvider.ts b/src/server/utils/versionProvider.ts index df83b4f..5a1afa8 100644 --- a/src/server/utils/versionProvider.ts +++ b/src/server/utils/versionProvider.ts @@ -116,15 +116,15 @@ export class TypeScriptVersionProvider { } public get bundledVersion(): TypeScriptVersion | null { - const file = requireFunc.resolve('typescript') - if (!file || !fs.existsSync(file)) { + try { + const file = requireFunc.resolve('typescript') + const bundledVersion = new TypeScriptVersion( + path.dirname(file), + '') + return bundledVersion + } catch (e) { workspace.showMessage('Bundled typescript module not found', 'error') return null } - const bundledVersion = new TypeScriptVersion( - path.dirname(file), - '' - ) - return bundledVersion } }