简体   繁体   中英

Visual Studio Code not performing error checking in Javascript

I've tried following these instructions:

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

As far as I know, they're running the default editor. I've tried installing typings and typescript using 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.

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?

Maybe you didn't use the -g flag to install them globally? Alternately, perhaps it's a missing jsconfig.json file?

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. At the top of my .js file I added the following line:

/// <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)

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. Otherwise, if there is a .eslint.js file but the ESLint dependency is not installed Visual Studio Code will report nothing in the editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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