无法编译。
/moonholdings.io/node_modules/@types/react-dom/node_modules/@types/react/index.d.ts (2312,14):标识符'LibraryManagedAttributes'重复。
不确定为什么要得到这个。
我已将"@types/node"
的等级从10降级为8,这是行不通的。
也尝试过"@types/node": "^9.6.7"
我的仓库:https://github.com/Futuratum/moonholdings.io
我的package.json
{
"name": "moonholdings.io",
"version": "0.1.0",
"private": true,
"scripts": {
"build-css": "node-sass-chokidar src/ -o src/ --source-map",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive --source-map",
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
},
"dependencies": {
"@types/react": "^16.4.14",
"@types/react-redux": "^6.0.9",
"node-sass-chokidar": "^1.3.3",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts-ts": "2.17.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@types/jest": "^23.3.2",
"@types/node": "^8.10.29",
"@types/react-dom": "^16.0.7",
"typescript": "^3.0.3"
}
}
这是我的tsconfig
{
"compilerOptions": {
"traceResolution": false,
"strictNullChecks": true,
"noImplicitAny": true,
"module": "esnext",
"target": "es5",
"lib": [
"es2015",
"es2017",
"es6",
"es7",
"es5",
"dom"
],
"jsx": "react",
"experimentalDecorators": true,
"moduleResolution": "node",
"baseUrl": "./src",
"noUnusedLocals": true,
"noUnusedParameters": false,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"strictFunctionTypes": false
},
"include": [
"src/**/*",
"webpack/**/*"
],
"files": [
"core.ts",
"sys.ts",
"types.ts",
"tsc.ts",
"registerServiceWorker.ts",
"src/registerServiceWorker.ts",
"src/setupTests.ts"
],
"exclude": [
"typings/browser.d.ts",
"typings/browser",
"typings",
"node_modules",
"build",
"scripts",
"acceptance-tests",
"webpack",
"jest"
]
}
答案 0 :(得分:1)
您可能会发现重复项位于node_modules/@types/react
和node_modules/types/react-dom/@types/react
或类似的设置中,其中一个程序包与另一个程序包具有嵌套依赖关系。
对我来说,一起修复和重新安装@ types / react-dom和@ types / react就是什么。
yarn remove @types/react-dom @types/react
yarn add @types/react-dom @types/react
答案 1 :(得分:0)
我仍然不确定是什么原因导致了该错误,但是我已经检查了我的应用程序的更早版本,该版本很稳定。因此,要从那里继续工作。
这是工作包。json
{
"name": "moonholdings.io",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"eject": "react-scripts-ts eject"
},
"dependencies": {
"@types/jest": "^23.3.1",
"@types/node": "^10.9.4",
"@types/react": "^16.4.13",
"@types/react-dom": "^16.0.7",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-ts-with-scss": "2.1.0",
"typescript": "^3.0.3"
},
"devDependencies": {}
}
答案 2 :(得分:0)
我有同样的错误。
我将@types/react和@types/react-dom升级到了package.json
的最新版本,并修复了我的错误。
不确定为什么在您的@types/react-dom
中而不是您的devDependencies
中定义了dependencies
,这也可能会解决...