【问题标题】:Visual studio code IntelliSense not working with NodeJSVisual Studio 代码 IntelliSense 不适用于 NodeJS
【发布时间】:2018-07-09 07:20:59
【问题描述】:

我一直在使用 vs code 开发 NodeJS 项目,但是 IntelliSense 不适用于我正在编写的类和文件,我尝试了 here 中的解决方案,但它对我不起作用,所以任何人都可以帮我解决这个问题。

VS代码版本:1.25.0

NodeJS 版本:8.9.4

一个关于智能感知问题的例子:

这是一个简单的类

正如您所看到的,当我从另一个文件中导入它时,没有 IntelliSense 正在工作 但是 node_module 文件 IntelliSense 正在工作!

【问题讨论】:

    标签: javascript node.js express visual-studio-code config


    【解决方案1】:

    我尝试用不同的语法来解决它来导出类:

    class Util {
        constructor() { }
    
        getNumber(x, y) {
            return x * y;
        }
    }
    
    exports.default = Util;
    

    然后,我可以像这样导入类

    const util = require('./../util/util').default;
    

    自动完成功能有效:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-14
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 2011-10-28
      • 2012-07-14
      • 1970-01-01
      • 2011-02-27
      相关资源
      最近更新 更多