Visual Studio Code Intellisense 不适用于 NPM 包 [英] Visual Studio Code Intellisense not working for NPM package

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

问题描述

我在 Windows 上使用 Visual Studio Code 1.20.0.我的智能感知无法正常工作,例如:visual studio 代码无法检测到 youtubedl 包具有 getinfo 方法.社区是否会就我需要做什么才能使智能感知正常工作提供意见?如果没有,我如何浏览 NPM 包以找到它公开的各种方法(在 .Net 中,我们可以使用对象资源管理器来做同样的事情)?

I am using Visual Studio Code 1.20.0 on Windows. My intellisense is not working correctly eg: visual studio code is not able to detect that the youtubedl package has getinfo method. Would the community have inputs on what I need to do to get intellisense working correctly? If not, how can I browse an NPM package to find the various methods exposed by it(In .Net we can do the same using an object explorer)?

推荐答案

如果您使用 ES6 导入,您将 需要一个 jsconfig.json 文件 在你的项目的根目录中.

If you're using ES6 imports, you'll need a jsconfig.json file in the root of your project.

下面是一个示例配置,allowSyntheticDefaultImports 是重要的选项,它将 可能会解决您的问题.

Below is an example config, with allowSyntheticDefaultImports being the important option that will likely solve your problem.

之后不要忘记重新启动 VSCode.

Don't forget to restart VSCode afterwards.

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "allowSyntheticDefaultImports": true,
  },
  "include": [
    "src/**/*"
  ],
}

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆