简体   繁体   English

Visual Studio Code 未在 Javascript 中执行错误检查

[英]Visual Studio Code not performing error checking in Javascript

I've tried following these instructions:我已经尝试按照以下说明进行操作:

https://code.visualstudio.com/Docs/runtimes/nodejs https://code.visualstudio.com/Docs/runtimes/nodejs

I am not getting the green/red swiggly lines at all.我根本没有得到绿色/红色的波浪线。 Is there something I'm missing?有什么我想念的吗?

You can also see the same thing in this video:您还可以在此视频中看到相同的内容:

https://youtu.be/sE8_bTEBlFg?t=1m37s https://youtu.be/sE8_bTEBlFg?t=1m37s

As far as I know, they're running the default editor.据我所知,他们正在运行默认编辑器。 I've tried installing typings and typescript using npm.我尝试使用 npm 安装类型和打字稿。 I've Followed that tutorial to get Javascript intellisense for node.js, but I fail to get either error/warning checking or any type information for node.js modules.我已经按照该教程获取 node.js 的 Javascript 智能感知,但我无法获取 node.js 模块的错误/警告检查或任何类型信息。

Is there a location the type files should be installed to in order to make them global to every JS project you create in VS Code?是否应该将类型文件安装到某个位置,以使它们对您在 VS Code 中创建的每个 JS 项目都是全局的?

Maybe you didn't use the -g flag to install them globally?也许您没有使用 -g 标志来全局安装它们? Alternately, perhaps it's a missing jsconfig.json file?或者,也许是缺少 jsconfig.json 文件?

OK, so I managed get get some code suggestions working after reading up online.好的,所以我在网上阅读后设法得到了一些代码建议。 Without using the whole Typings tools, I acquired node.d.ts (found it on my computer inside C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions) and placed that in my project's directory structure inside the ".vscode" folder.在没有使用整个 Typings 工具的情况下,我获得了 node.d.ts(在我的计算机上的 C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions 中找到它)并将其放在我项目的目录结构中“.vscode”文件夹。 At the top of my .js file I added the following line:在我的 .js 文件的顶部,我添加了以下行:

/// <reference path=".vscode/node.d.ts" />

The code seems to be recognized now.该代码现在似乎已被识别。 I read up on this tip here: How to Import Intellisense files into vsCode (Visual Studio Code)我在这里阅读了这个提示: 如何将 Intellisense 文件导入 vsCode (Visual Studio Code)

If you are using ESLint and you have an .eslint.js file in the project root you also need the eslint dependency installed in the project.如果你使用 ESLint 并且在项目根目录中有一个.eslint.js文件,你还需要在项目中安装eslint依赖项。 Otherwise, if there is a .eslint.js file but the ESLint dependency is not installed Visual Studio Code will report nothing in the editor.否则,如果有.eslint.js文件但未安装 ESLint 依赖项,Visual Studio Code 将在编辑器中不报告任何内容。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM