Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coc-tsserver not recognizing @types/node #474

Open
gatoasmatico opened this issue Sep 11, 2024 · 5 comments
Open

coc-tsserver not recognizing @types/node #474

gatoasmatico opened this issue Sep 11, 2024 · 5 comments

Comments

@gatoasmatico
Copy link

I'm on windows, using vim through MSYS2, and i'm trying to use coc-tsserver to work on a Nodejs project, but the extension isn't recognizing node built-in modules, not even the global variables like Buffer. Is this a problem from MSYS or the extension?
image

I also noticed that :CocConfig is not auto-completing some tsserver configuration options like "tsserver.log"
image

I also use this extension on my Android through termux and it works perfectly.
Node and NPM have been installed from nodejs.org and can be accessed by MSYS via "MSYS2_PATH_TYPE=inherit" in msys2.ini.
I've already run both npm install typescript @types/node and npm install --global typescript @types/node.
I can provide tsserver.log, but I don't think I should just paste the text here because it has many lines, so if anyone wants me to send the tsserver.log, please tell me the best way.

@fannheyward
Copy link
Member

Try import http from 'node:http', looks like something wrong in your tsconfig.json?

@gatoasmatico
Copy link
Author

I replaced const http = require("node:http") with import http from 'node:http' and it still doesn't recognize it. I don't have a tsconfig.json file because I'm not using TypeScript, I'm using JavaScript.

@fannheyward
Copy link
Member

Check the QA in README https://github.com/neoclide/coc-tsserver?tab=readme-ov-file#q--a

You need to setup jsconfig.json to make tsserver understand your code.

@gatoasmatico
Copy link
Author

I created a jsconfig.json on my project root with { "include": ["./main.js"], "module": "ES6", "checkJs": true } , i added npm global path and the coc-status line, which only shows "Initializing tsserver" and "TSC 5.6.2". Nothing has changed, still not recognizing.

@gatoasmatico
Copy link
Author

I ran npm --global install [email protected] and configured tsserver.tsdk to use it and now it works!
image

When I was trying to figure out why it was working in termux but not in MSYS, I noticed that the TSC version in my termux was 5.5.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants