sourcegraph / javascript-typescript-langserver

JavaScript and TypeScript code intelligence through the Language Server Protocol
https://sourcegraph.com
Apache License 2.0
792 stars 72 forks source link

Code completion in Node project #561

Open ferrao opened 5 years ago

ferrao commented 5 years ago

I have been scratching my head for a while on how to get code completion to work with a NodeJS project. All my node projects set NODE_PATH=src:..

This is the best way that I found to avoid things like:

const myModule = require('../../../../some-other-module');

I can now simply do :

const myModule = require('some-other-module');

But code completion does not work at all. Typing myModule. reveals lots of wrong stuff, nothing related to the module contents.

Any pointers on how to properly configure the language server? I have tried all settings.json and jsconfig.json snippets I have found, always without success. I have navigated through many web pages and tried all sorts of configurations, but the result is always the same.

malob commented 5 years ago

Pretty sure completions for javascript files are dependent on type information, and so you'll need to install the types for the modules your working with. Try npm install --save-dev @types/node.

You can search for type definition packages here: http://definitelytyped.org

ferrao commented 5 years ago

I'm referring to my own code @malob , not some external project dependency. And all my code is plain JavaScript.