简体   繁体   中英

Make Visual Studio Code recognise module and require

Visual Studio Code underlines require and module keywords in my .js files which I run with Node. How to prevent this from happening?

Since Visual studio code is written in TypeScript you need to download type definitions for nodejs. To do this click on the text (require/ module) which is underlined. Now it would show a yellow bulb.

在此处输入图片说明

Now click on that yellow bulb. A menu should open , select Download type definition for node.d.ts . Done visual studio code will download the type files for you.

在此处输入图片说明

Now a typings folder will display in your project folder , remember to add that in your .gitignore file to avoid unnecessary file commit to your git repo

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