TypeScript error: Duplicate identifier 'LibraryManagedAttributes'

前端 未结 3 525
Happy的楠姐
Happy的楠姐 2021-01-13 20:23

Failed to compile.

/moonholdings.io/node_modules/@types/react-dom/node_modules/@types/react/index.d.ts (2312,14): Duplicate identifier \'LibraryManagedAt

相关标签:
3条回答
  • 2021-01-13 20:41

    I'm still not sure what caused that bug, however I've checked out a much earlier version of my app, where it was stable. So going to continue work from there.

    Here is the working package.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": {}
    }
    
    0 讨论(0)
  • 2021-01-13 20:42

    I had the same error. I upgraded @types/react and @types/react-dom to their latest versions in package.json and it fixed my error.

    Not sure why @types/react-dom is defined in your devDependencies instead of your dependencies, that might fix it as well...

    0 讨论(0)
  • 2021-01-13 20:46

    You may find that the duplicates are located in node_modules/@types/react and node_modules/types/react-dom/@types/react or a similar set-up, in which one of the packages has a nested dependency on the other.

    Uninstalling and reinstalling @types/react-dom and @types/react together is what fixed it for me.

    yarn remove @types/react-dom @types/react
    
    
    yarn add -D @types/react-dom @types/react
    
    0 讨论(0)
提交回复
热议问题