我正在使用 tsc 构建任务。不幸的是,我总是从 Node 模块文件夹中得到同样的错误
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",
]
}
我做错了什么?我应该怎么做才能忽略这些错误?
我正在使用 VsCode 和 tsc 版本 2.9.2
最佳答案
Quickfix 就是跳过检查
{
"compilerOptions": {
"skipLibCheck": true
},
}
关于node.js - 如何强制 tsc 忽略 node_modules 文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51634361/