VSCode 遭遇typescript language server 初始化失败

Fork Me On Github
zodream DEBUG问题集 2018年12月

症状

同一个项目,在笔记本上打开是正常的,到了台式机上一直在初始化 typscript 语言服务,

输出显示

text
               

[Error  - 9:59:09 PM] ReaderError
RangeError: out of range index
    at Buffer.copy (buffer.js:602:18)
    at l.tryReadContent (d:\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:161851)
    at t.Reader.onLengthData (d:\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:162417)
    at Socket.t.Reader.i.Disposable.constructor.e.on.e (d:\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:162184)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)
[Error  - 9:59:09 PM] TSServer exited with code: 3
123456789101112131415

解决方法

  1. 在设置里增加 "typescript.tsserver.log": "verbose",
  2. 重启vscode,再次查看输出,会在第二行出现日志文件路径
  3. 等到输出报错后,打开日志文件,查看报错原因
  4. 才发现是有.ts视频文件也被识别进去
  5. 删除.ts视频文件或在 tsconfig.json 加入排除文件夹 "exclude": []

报错原因有多种具体请用1、2、3步自行查看或到vscode 提交issues并附上日志内容

点击查看全文
0 3252 0