如何在 VSCode 中的 TypeScript 构建期间忽略 `node_modules` 文件夹 [英] How to ignore `node_modules` folder during TypeScript build in VSCode
本文介绍了如何在 VSCode 中的 TypeScript 构建期间忽略 `node_modules` 文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Visual Studio 代码 IDE 和打字稿,如何让它在构建过程中忽略 node_modules 文件夹?或者它在保存时构建 .ts
文件?它显示了很多错误,因为它正在尝试编译 node_modules tsd.
I'm using visual studio code IDE and typescript, how do I get it to ignore the node_modules folder during build? Or have it build .ts
files on save? It is showing a lot of errors because it's trying to compile node_modules tsd.
目前我的 tasks.json 是
Currently my tasks.json is
{
"version": "0.1.0",
// The command is tsc.
"command": "tsc",
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// Under windows use tsc.exe. This ensures we don't need a shell.
"windows": {
"command": "tsc.exe"
},
"isShellCommand": true,
// args is the HelloWorld program to compile.
"args": [],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
推荐答案
您现在可以在 tsconfig.json 文件中使用 exclude
:
You can now use exclude
in your tsconfig.json file:
{
"exclude": [
"node_modules",
],
"compilerOptions": {
...
}
}
https://github.com/Microsoft/TypeScript/wiki/tsconfig.json
请注意,它是 compilerOptions 的兄弟,而不是其子项.
Note it's a sibling to, not child of, compilerOptions.
这篇关于如何在 VSCode 中的 TypeScript 构建期间忽略 `node_modules` 文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文