Visual Studio Code IntelliSense not working for Node.js

爷,独闯天下 提交于 2021-01-27 05:22:41

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/51960501/visual-studio-code-intellisense-not-working-for-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!