sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
132 stars 11 forks source link

Cannot start language server #159

Closed jacksonzamorano closed 1 year ago

jacksonzamorano commented 1 year ago

I started Sublime Text today and found out that for some reason the server cannot start.

LSP-typescript: /Users/jacksonzamorano/Library/Caches/Sublime Text/Package Storage/LSP-typescript/12.13.0/typescript-language-server/node_modules/typescript-language-server/lib/cli.js:8
LSP-typescript: import { readFileSync } from 'node:fs';
LSP-typescript: ^^^^^^
LSP-typescript: 
LSP-typescript: SyntaxError: Cannot use import statement outside a module
LSP-typescript:     at Module._compile (internal/modules/cjs/loader.js:892:18)
LSP-typescript:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
LSP-typescript:     at Module.load (internal/modules/cjs/loader.js:812:32)
LSP-typescript:     at Function.Module._load (internal/modules/cjs/loader.js:724:14)
LSP-typescript:     at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
LSP-typescript:     at internal/main/run_main_module.js:17:11

It appears that the issue lies in the cli.js file provided by typescript-language-server is not truly a js file; it is still a TypeScript file. This happens with typescript-language-server versions 1.1.1 and 1.1.2.

predragnikolic commented 1 year ago

What is your Node version? The minimum required version is Node 14

https://github.com/typescript-language-server/typescript-language-server/releases/tag/v1.0.0

rchl commented 1 year ago

We can see from the path that it's 12.13.0.

Added a minimum Node version constraint in https://github.com/sublimelsp/LSP-typescript/commit/75bca930fe7652b6aa8f20d8e69f9e62e383157d to give a proper error message in this case.

jacksonzamorano commented 1 year ago

@rchl @predragnikolic Thanks for your help! Apparently my system node version was overriding my NVM version in Sublime only. The latest update offered to download Node for me, and that fixed it.

I really appreciate your help!