本文介绍了Visual Studio Code IntelliSense 不适用于 Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在发布这个问题之前,我已经浏览了以下主题.

解决方案

在变量 之前没有 constletvarfsObj,该变量具有全局"作用域.关于这一点似乎阻止了 vscode 能够将正确的智能感知参数分配给该变量.添加其中之一,如 const,提供了智能感知工作的不同范围.我无法确切解释是什么阻止了智能感知,也许该变量绑定到作用域链中更高的某些内容,从而阻止了它的工作.

在任何情况下,如果使用严格模式,不包含 const/let/var 都会导致错误.

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.

解决方案

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.

这篇关于Visual Studio Code IntelliSense 不适用于 Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 21:20