Javascript 类型脚本错误:重复标识符';图书馆管理奖';
未能编译 /moonholdings.io/node_modules/@types/react dom/node_modules/@types/react/index.d.ts (2312,14):重复标识符“LibraryManagedAttributes” 不知道为什么我会得到这个 我已经将我的Javascript 类型脚本错误:重复标识符';图书馆管理奖';,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,未能编译 /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” 我的回购协议: mypackage.json { "name":
“@types/node”
从10降到了8,但这不起作用。
还尝试了“@types/node”:“^9.6.7”
我的回购协议:
mypackage.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"
}
}
{
"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": {}
}
这是我的配置
{
"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"
]
}
我仍然不确定是什么导致了这个bug,但是我已经检查了我的应用程序的一个更早的版本,在那里它是稳定的。因此,我们将继续从那里工作 这是工作包.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"
}
}
{
"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": {}
}
我也犯了同样的错误。
我在package.json
中将和升级到了它们的最新版本,它修复了我的错误
不确定为什么
@types/react dom
是在您的devDependencies
中定义的,而不是您的依赖项
,这可能也会修复它…您可能会发现重复项位于节点模块/@types/react
和节点模块/类型/react dom/@types/react>或类似设置中,其中一个包对另一个包具有嵌套依赖关系
卸载并重新安装@types/react dom和@types/react是我修复它的方法
yarn remove @types/react-dom @types/react
yarn add -D @types/react-dom @types/react
现在您有了node\u modules/@types/react dom/node\u modules/@types/react/index.d.ts
和node\u modules/@types/react/index.d.ts
?我认为您的项目类型依赖项必须与您的可传递类型依赖项相匹配。@Leon Gaban@zerkms是的,我有both@zerkms好的,所以我删除了React类型,现在得到了其他奇怪的错误……这个问题的答案到目前为止也没有帮助:(但仍在深入研究。这并没有解决我的问题。我想如果你删除你的node\u modules
文件夹并重新安装warn
和warn build
,错误将再次出现。我发现了另一个解决方法:你为什么接受自己的答案?这不是一个真正的解决方案。非常感谢!尝试了这么多不同的方法。)nt技巧在这里形成:但这非常有效。这不是因为typescript代码只用于开发吗?一旦它被传输用于部署,它就是javascript,所以类型不再是必需的?类型不总是menat是dev deps吗