Typescript 类型脚本重复要求@types/node中出现错误
尝试构建我的第一个typescript项目后,出现以下错误:Typescript 类型脚本重复要求@types/node中出现错误,typescript,Typescript,尝试构建我的第一个typescript项目后,出现以下错误: yarn run v1.3.2 $ yarn tsc $ tsc node_modules/@types/node/index.d.ts(139,13): error TS2300: Duplicate identifier 'require'. node_modules/@types/react-native/index.d.ts(8618,14): error TS2300: Duplicate identifier 'requi
yarn run v1.3.2
$ yarn tsc
$ tsc
node_modules/@types/node/index.d.ts(139,13): error TS2300: Duplicate identifier 'require'.
node_modules/@types/react-native/index.d.ts(8618,14): error TS2300: Duplicate identifier 'require'.
我不确定是什么导致了这个错误。我甚至在tsconfig.json
中的exclude
中有node\u模块。以下是相关文件:
tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "es2015",
"moduleResolution": "node",
"jsx": "react",
"outDir": "artifacts",
"rootDir": "src",
"allowSyntheticDefaultImports": true,
"noImplicitAny": false,
"preserveConstEnums": true,
"allowJs": false,
"sourceMap": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"noUnusedLocals": true
},
"filesGlob": [
"src/**/*.ts",
"src/**/*.tsx"
],
"types": [
"react",
"react-native",
"jest"
],
"exclude": [
"android",
"ios",
"build",
"node_modules"
],
"compileOnSave": false
}
package.json
依赖项
"dependencies": {
"react": "16.0.0",
"react-native": "0.51.0"
},
"devDependencies": {
"@types/jest": "^22.0.1",
"@types/react": "^16.0.34",
"@types/react-native": "^0.51.9",
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"concurrently": "^3.5.1",
"jest": "22.0.4",
"react-test-renderer": "16.0.0",
"rimraf": "^3.6.2",
"tslint": "^5.8.0",
"typescript": "^2.6.2"
},
尝试删除tsconfig.json中的类型