如何强制 tsc 忽略 node_modules 文件夹? [英] How to force tsc to ignore node_modules folder?

查看:190
本文介绍了如何强制 tsc 忽略 node_modules 文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 tsc 构建任务.不幸的是,我总是从节点模块文件夹中收到相同的错误

I'm using tsc build tasks. Unfortunately I'm always getting the same errors from the node modules folder

Executing task: .\node_modules\.bin\tsc.cmd --watch -p .\tsconfig.json <
node_modules/@types/node/index.d.ts(6208,55): error TS2304: Cannot find name 'Map'.
node_modules/@types/node/index.d.ts(6215,55): error TS2304: Cannot find name 'Set'.
node_modules/@types/node/index.d.ts(6219,64): error TS2304: Cannot find name 'Symbol'.
node_modules/@types/node/index.d.ts(6225,59): error TS2304: Cannot find name 'WeakMap'.
node_modules/@types/node/index.d.ts(6226,59): error TS2304: Cannot find name 'WeakSet'.
10:13:18 - Compilation complete. Watching for file changes.

我已经将目录添加到 tsconfig.json


    {
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "strict": false,
        "noImplicitAny": false,
        "strictPropertyInitialization": false,
        "esModuleInterop": true,
      },
      "include": [
        "src/*"
      ],
      "exclude": [
        "node_modules",
        "./node_modules",
        "./node_modules/*",
        "./node_modules/@types/node/index.d.ts",
      ]
    }

我做错了什么?我应该怎么做才能忽略这些错误?

What I'm doing wrong? What should I do in order to ignore those errors?

我使用的是 VsCode 和 tsc 版本 2.9.2

I'm using VsCode and tsc Version 2.9.2

推荐答案

Quickfix 是跳过检查

Quickfix is to skip the check

{
  "compilerOptions": {
    "skipLibCheck": true
  },
}

这篇关于如何强制 tsc 忽略 node_modules 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆