Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 类型脚本重复要求@types/node中出现错误_Typescript - Fatal编程技术网

Typescript 类型脚本重复要求@types/node中出现错误

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

尝试构建我的第一个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 '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中的
类型