I have installed Visual Studio Code and Node.js and both basically work, but autocomplete is not (completely) working. If I type 'console.' I do indeed see a list popup. Likewise if I do: const http = require("http"); http.
But if I simply type 'process.' I don't see anything. In fact as soon as I type '.' Code autocompletes 'process' to 'ProcessingInstruction'. I was expecting to see argv pop up, along with all the other stuff you see if you type 'process' at a Node prompt.
Here's what I see when I type 'console.': Yay -- it works!
But here's what I see when I type 'process.' (I have to change the autocompleted 'ProcessingInstruction' back to 'process'): Boo -- it doesn't know 'process'! :(
You will need to tell VS Code about the types in Node JS (as you hit at yourself in the comment). To do this you can install the types for node running the following command (assuming you have already run npm init
):
npm install --save-dev @types/node
It will install the types for Node JS, which VS Code automatically picks up and you'll be auto-completing all Node JS-specific things going forward. You don't even have to restart VS Code.
As you are adding more dependencies to your project (if you will be doing so). Many of them have a @types/X package as well (if they don't have the already included in the package), which will allow autocomplete as well.
Per Microsoft's Documentation: https://code.visualstudio.com/docs/nodejs/working-with-javascript
IntelliSense for JavaScript libraries and frameworks is powered by TypeScript type declaration (typings) files.
Automatic type acquisition requires npmjs, the Node.js package manager, which is included with the Node.js runtime.
In my situation, I do not have npmjs installed and that's why automatic type acquisition fails.
*Edit, that is, after installing npm, my autocomplete starting working successfully for node related hints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With