Git Product home page Git Product logo

Comments (11)

svenefftinge avatar svenefftinge commented on August 23, 2024 1

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:

  1. workspace (node_modules)
  2. global install (i.e. tsserver is on path)
  3. shipped with typescript-language-server

from typescript-language-server.

svenefftinge avatar svenefftinge commented on August 23, 2024

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.

angelozerr avatar angelozerr commented on August 23, 2024

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.

svenefftinge avatar svenefftinge commented on August 23, 2024

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.

angelozerr avatar angelozerr commented on August 23, 2024

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.

svenefftinge avatar svenefftinge commented on August 23, 2024

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.

svenefftinge avatar svenefftinge commented on August 23, 2024

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.

angelozerr avatar angelozerr commented on August 23, 2024

When I do npm install typescript in MY_PROJECT folder, I have that:

  • MY_PROJECT
    • node_modules
      • .bin
        • tsserver.cmd
        • tsserver
      • typescript
        • bin
        • lib

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.

prabirshrestha avatar prabirshrestha commented on August 23, 2024

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.

svenefftinge avatar svenefftinge commented on August 23, 2024

Thanks, this should work, no?
#11

from typescript-language-server.

angelozerr avatar angelozerr commented on August 23, 2024

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 that npm 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 with npm install -g typespcript

from typescript-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.