How to enable Node.js code autocompletion in VSCode? How to enable Node.js code autocompletion in VSCode? node.js node.js

How to enable Node.js code autocompletion in VSCode?


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 are using pure javascript for your node app, when including the required modules, they should be defined with single quotes instead of double-quotes. If you were using a code formatter extension like "Prettier" for instance, it adds it by default before the IntelliSense, then you would have to update your settings to use single quote.