javascript-typescript-langserver icon indicating copy to clipboard operation
javascript-typescript-langserver copied to clipboard

Error importing modules from node_modules, even though tsc runs fine.

Open keyboardDrummer opened this issue 6 years ago • 4 comments

I have a project that has no errors when running tsc on it, but will show errors when opening it in VSCode with the javascript-typescript-langserver extensions.

The problem occurs because of a peculiar directory structure, which is this:

- node_modules
  - events
- src
  - tsconfig.json
  - index.ts //contains `import { EventEmitter } from "events"`, which has an error.
- package.json

Also note that in VSCode I open the folder 'src', so that the root of the LSP server will be ./src, not ./ If I run tsc from the ./src directory, it runs fine without errors, but in VSCode, any imports from node_modules will error with 'Could not find module '

To reproduce:

  • Clone https://github.com/keyboardDrummer/repro-ts-server-sourcegraph-issue
  • Install the javascript-typescript-langserver extension in VSCode
  • Open the src directory in VSCode
  • Open the index.ts file
  • Note the incorrect error on the import

keyboardDrummer avatar May 22 '18 14:05 keyboardDrummer

Is there no one maintaining this project?

ghost avatar Aug 21 '18 12:08 ghost

I am seeing this as well -- did you make any progress?

hifall avatar Sep 21 '18 06:09 hifall

This issue is resolved by this PR. However I would recommend using the TypeFox LSP server since it's made for IDE usage and has a much simpler architecture.

keyboardDrummer avatar Sep 21 '18 08:09 keyboardDrummer

Same issue, more than one year and a half later. I’ve followed your advice, and switched to server from Theia IDE.

concatime avatar Jan 05 '20 05:01 concatime