Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code IntelliSense not working for Node.js

I have gone through the following threads before posting this question.

Visual Studio Code: Intellisense not working

Visual Studio Code Intellisense not working for Javascript

I have Visual Studio version 1.26.1 on my Windows 10 laptop.

I am learning Node.Js, so I wanted to learn various functionalities in 'FS' module. I created a new file called 'app1.js' in Visual Studio Code, and wrote the following line of code.

fsObj = require('fs');

After this when I typed fsObj. to see what functions/properties are available under the fs object, I get a list with only two objects, which are not elements of the 'fs' module. I do not understand why IntelliSense is not showing the elemetns of 'fs' module. I am pasting a screen shot of the VS Code screen.

enter image description here

like image 651
KurioZ7 Avatar asked Oct 16 '22 14:10

KurioZ7


1 Answers

Without const, let or var before your variable fsObj, that variable has a 'global' scope. Something about that seems to prevent vscode from being able to assign the proper intellisense parameters to that variable. Adding one of those, like const, provides a different scope where the intellisense works. I cannot explain exactly what is preventing intellisense, perhaps the variable is bound to something higher in the scope chain that prevents it working.

In any case, failing to include const/let/var would result in an error if strict mode was used.

like image 163
Mark Avatar answered Oct 21 '22 05:10

Mark