Visual Studio Code Intellisense not working for Javascript
I experienced this on global "process" object. Vscode enabled intellisense for process object, only if I add any "require" statements to the file.
So if there is not any other require statements, you can add
const process = require('process');
in the beginning of your script to get intellisense.
The above links are outdated. In older versions of VS Code you needed to reference your typings like /// <reference path> for somelibrary.d.ts
.
With new version you need to initialize your project by creating jsconfig.json
at the root of your project and add the following inside:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"exclude": [
"node_modules"
]
}
Next install typing you need. You can use either tsd or typings. In your case you need to install tsd install node
or typings install node --ambient
. Make sure you have typings/tsd
installed. Restart project.
Please refer to docs:
- Setup JS project - https://code.visualstudio.com/docs/languages/javascript
- Node.js - https://code.visualstudio.com/docs/runtimes/nodejs
- Debugging - https://code.visualstudio.com/docs/editor/debugging
Update:
Since version 1.7 there is no need to manually install typings, they should be downloaded automatically. Better JavaScript IntelliSense
There is a built-in extension called TypeScript and JavaScript Language Features (vscode.typescript-language-features) that is disabled.
In order to enable it, open Extensions panel, search for "@built-in JavaScript", and enable the required extension.
Now you should be able to use the autocomplete feature.