简体   繁体   English

JavaScript Intellisense与Visual Studio代码:如何让它适用于所需的模块?

[英]JavaScript Intellisense with Visual Studio Code: How to get it to work for required modules?

For some reason, intellisense won't work for me for required modules. 出于某种原因,intellisense对我来说不适用于所需的模块。 At least out-of-the box. 至少是开箱即用的。 For example (this is JS code): 例如(这是JS代码):

const fs = require(‘fs’); 

won't kick intellisense when typing: 键入时不会触发intellisense:

fs. 

further down the code. 进一步下来的代码。

However, if I install "some" modules in the project's node_modules directory (running the $ npm install command), I will get intellisense to work after bouncing it. 但是,如果我在项目的node_modules目录中安装“some”模块(运行$ npm install命令),我将弹跳获得intellisense工作。 Regardless of which modules were installed (apparently). 无论安装哪个模块(显然)。

Even more puzzling, removing the node_modules altogether will make intellisense continue to work. 更令人费解的是,完全删除node_modules将使intellisense继续工作。 Even bouncing VS Code won't affect intellisense, which will continue to work from this point onward. 即使弹跳VS Code也不会影响智能感知,智能感知将从此时起继续发挥作用。

It looks like installing "some" modules somehow fixed whatever wasn't right for intellisense. 看起来安装“某些”模块以某种方式修复了任何不适合intellisense的东西。 Question is, where is this fix living? 问题是,这个修复生活在哪里? In a file? 在文件中? And what is it? 还有,这是什么?

PS: I am using VS Code version 1.7.2 with Node 6.5.0, on Ubuntu Mate 16.04. PS:我在Ubuntu Mate 16.04上使用VS Code 1.7.2版和Node 6.5.0。

  • First check if you have jsconfig.json in your source folder 首先检查源文件夹中是否有jsconfig.json
  • Then install typings 然后安装打字
  • With typings now you can install the dt package. 现在有了打字,你可以安装dt包。 Search for the node version you need, command line: typings search node . 搜索所需的节点版本,命令行: typings搜索节点
    Install with something like: typings install dt~node --global --save 安装类似于: typings install dt~node --global --save
  • Just in case reopen vscode. 以防重新打开vscode。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio Code Intellisense 不适用于 Javascript - Visual Studio Code Intellisense not working for Javascript 用于引导脚本中全局注册模块的 Visual Studio Code 智能感知 - Visual Studio Code intellisense for globally registered modules in a bootstrapping script 使用JavaScript的Visual Studio代码以及TypeScript文件作为Intellisense的参考 - Visual Studio Code using JavaScript with a TypeScript File as Reference for Intellisense Visual Studio 代码智能感知在 javascript 文件中的自动完成 function 调用中不起作用 - visual studio code intellisense not working in autocompleted function call in javascript files 如何获得Visual Studio Typescript 1.7智能感知以使用Node.js库(Angular2,rxjs)? - How can I get Visual Studio Typescript 1.7 intellisense to work with nodejs libraries (angular2, rxjs)? 如何将 Intellisense 文件导入 vsCode (Visual Studio Code) - How to Import Intellisense files into vsCode (Visual Studio Code) Visual Studio Code 中的异步智能感知节点JS - Asynchronus Intellisense in Visual Studio Code | NodeJS Visual Studio Code 中的 .ts 文件没有智能感知 - No intellisense for .ts files in Visual Studio Code Visual Studio Code Typescript Intellisense停止工作 - Visual Studio Code Typescript Intellisense stops working Visual Studio代码IntelliSense无法与NodeJS一起使用 - Visual studio code IntelliSense not working with NodeJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM