Typescript duplicate需要@ types / node中的错误

时间:2018-01-07 07:24:16

标签: 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'.

我不确定是什么原因导致此错误。我node_modules中的exclude中甚至tsconfig.json。以下是相关文件:

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"
  },

0 个答案:

没有答案