Comments (11)
The strategy to lookup in the typescript-language-server node_modules would already always find it. The language server wouldn't work if there was no typescript. So what should be the correct order?
I propose:
- workspace (node_modules)
- global install (i.e.
tsserver
is on path) - shipped with typescript-language-server
from typescript-language-server.
My plan was to find and use the tsserver
of the current project, by looking into the node_modules of the parent dirs. But that could be the default strategy, which could be overwritten with a settings file.
from typescript-language-server.
I like your idea, but I have tried with Windows and I have this error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn d:\_Personal\runtime-EclipseApplicationBlueSky\Test\node_modules\typescript\bin\tsserver ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Although d:_Personal\runtime-EclipseApplicationBlueSky\Test\node_modules\typescript\bin\tsserver exists.
Perhaps the problem comes from that my typescript-lsp is hosted in the C drive ?
from typescript-language-server.
As I don't have a windows system it would be really awesome if you could try to figure out what is wrong.
from typescript-language-server.
After some test, it seems that in Windows OS
you cannot execute the typescript/bin/tsserver
.
To support Windows OS, you must execute typescript/lib/tsserver.js
with node
In other words do like this:
this.tsserverProc = cp.spawn("node", ["YOUR_PROJECT/node_modules/typescript/lib/tsserver.js"]);
from typescript-language-server.
ok, thanks for checking. Should not be too hard to have the alternative case for windows, then.
Ar you going to take a crack at it?
from typescript-language-server.
So is the tsserver.cmd
file only present when you install typescript using the installer, but not part of an install via npm on windows?
from typescript-language-server.
When I do npm install typescript
in MY_PROJECT
folder, I have that:
- MY_PROJECT
- node_modules
- .bin
- tsserver.cmd
- tsserver
- typescript
- bin
- lib
- .bin
- node_modules
I think you should have the same behaviour with Unix.
To support with clean mean tsserver with any OS, you have 2 choices
- execute tsserver.cmd for windows and tsserver for other OS which is hosted inside
.bin
folder:
this.tsserverProc = cp.spawn("YOUR_PROJECT/node_modules/.bin/tsserver.cmd"...
- execute tsserver.js with node :
this.tsserverProc = cp.spawn("node", ["YOUR_PROJECT/node_modules/typescript/lib/tsserver.js"]);
Those 2 solutions should work with any OS.
from typescript-language-server.
You need to change this so that if on windows it uses tsserver.cmd
instead of tsserver
.
const path = findPathToModule(this.rootPath(), 'typescript/bin/tsserver')
return path || 'tsserver'
I would have something like this.
function getDefaultTsserverBinFile() {
return isWindows() ? 'tsserver.cmd' : 'tsserver';
}
const defaultTsserverBinFile = getDefaultTsserverBinFile();
const path = findPathToModule(this.rootPath(), path.join('typescript/bin', defaultTsserverBinFile))
return path || defaultTsserverBinFile
This is something similar to the PR I sent earlier. #8
from typescript-language-server.
Thanks, this should work, no?
#11
from typescript-language-server.
Thanks, this should work, no?
Yes #11 works like a char in Windows.
Today tsserver.cmd is searched with 2 means:
- in
MY_PROJECT/node_modules/typescript/.bin/tsserver.cmd
- in
tsserver.cmd
which means thatnpm install -g typespcript
was done.
I think a last strategy should be added:
-
search the typescript bundle which is in the same node_modules than typescript-language-server (when you install typescript-language-server with npm). In my case I need that, because I would like to provide an Eclipse plugin https://github.com/mickaelistria/eclipse-bluesky/ which embeds typescript-language-server. When user install the Eclipse plugin and opens a ts or js files, it should work:
-
without installing typescript with
npm install typespcript
or withnpm install -g typespcript
from typescript-language-server.
Related Issues (20)
- Support renaming files when renaming default exports
- (bug) Closed document ownership not transferred back to the filesystem HOT 5
- Use diagnostic range when requesting `getCodeFixes` HOT 4
- checkJs on not respected with declaration files HOT 2
- Completion items have incorrect "kind" HOT 6
- Typescript Server Error when `includeInlayVariableTypeHints = true` and an arrow function is made. HOT 1
- Deprecated property not marked as such HOT 3
- problems with `interface` structure HOT 3
- How to Disable "Move to a new file" action? HOT 2
- typescript server error when using 'inlay hints' (Unexpected node.^M) HOT 1
- Debug Failure. Unexpected node. HOT 5
- env: node: No such file or directory on MacOS HOT 3
- SyntaxError: Unexpected token import HOT 1
- importModuleSpecifierEnding is not respected HOT 1
- Unable to initialize, language server cannot read properties of undefined (reading 'workspace') HOT 1
- Add Semantic Tokens for Template Literal Strings HOT 1
- Ignore typescript type errors in `.js` / `.jsx` files HOT 3
- neovide GUI "env: node: No such file or directory HOT 1
- Is it possible to filter build-in types? HOT 1
- Does not format .tsx files HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript-language-server.