score:0
in my case, i got the error indicate that 'librarymanagedattributes' is declared in 2 different locations. follow the paths, i realized that an installed module also has a package.json file which also add "@types/react" as dep, and its version is not the same as the one in the root package.json file. i changed these two to the same version and the problem was solved.
score:0
i had a conflicting version request for react in another module i used. fixing that and re-installing with yarn didn't help me either.
using npm instead of yarn however solved it for me.
hope this helps someone.
score:0
what worked for me was deleting react
and @types/react
from package.json
, then in zsh:
rm -rf node_modules/**/react
npm i react @types/react
score:0
for me, it caused by only referenced @types/react-redux
. fixed by npm i --save-dev @types/react
, and so the package.json
looks like this:
...
"devdependencies": {
"@types/react": "^16.9.19",
"@types/react-redux": "^7.1.7"
...
}
score:0
i had this issue while working with linked dependencies. my linked package lives in a lerna repo, and it had @types/react
as a devdependency. i added @types/react
as a peerdependency, switched my workflow to yalc, and was able to continue.
score:1
c:/users/japa/source/repos/reacttestapp/templateexample/clientapp/node_modules/@types/react/index.d.ts
typescript error in c:/users/japa/source/repos/reacttestapp/templateexample/clientapp/node_modules/@types/react/index.d.ts(2835,14):
duplicate identifier 'librarymanagedattributes'. ts2300
in my case i needed to solve the problem manually (using principle described in ts2300). the problem arose once i added reactkendo to my project.
- went to
clientapp
directory in my projectclientapp\node_modules\@types
- backed up the
react
directory and then deleted it - clean + build + run project and no more above error occures
- i recovered the
react
folder after the bug disappeared and error seems to be gone forever, so it seems to me like typical magic bug somewhere in the universe :-)
i did not need to change anything else in config files.
score:2
i have the same issue after yarn upgrade @types/react-router-dom
. git diff
shows multiple versions of @types/react
resolved. in my case, yarn upgrade @types/react
resolves the issue. removing yarn.lock
should help.
it seems a fresh (without yarn.lock
) install would resolve packages to a consistent state, but a partial upgrade would not resolve the dependencies globally. thus manual tweaks may be necessary to upgrade all involved packages.
score:3
related to the question, running npm list @types/react
from the directory of your package.json should list duplicate type definitions found in your project.
score:3
using yarn-deduplicate fixed the issue for me.
steps:
- optional install
yarn-deduplicate
package or usenpx
in step two
npm install -g yarn-deduplicate
or
yarn global add yarn-deduplicate
- run
yarn-deduplicate
yarn-deduplicate yarn.lock --packages @types/react yarn.lock
or
npx yarn-deduplicate --packages @types/react yarn.lock
- remove
node_modules
folder
rm -rf node_modules
- reinstall dependencies
yarn install
score:4
in our case, we fixed it by
moving all
@types/*
packages todevdependencies
rm -rf yarn.lock
andrm -rf node_modules
run
yarn install
again
score:5
in my case the error showed up when the version numbers of @types/react
(v17.0.3) and @types/react-dom
(v17.0.2) have not been in sync.
to solve the issue, i removed @types/react
because it gets hoisted from @types/react-dom
. you can verify that by executing yarn why @types/react
.
score:7
the easiest way to fix this for me was to delete my node_modules directory and yarn.lock/package-lock files and then do a yarn install to reinstall all the node modules.
score:20
for me i had react types duplicated in react-redux
, react
, and react-intl
when i upgraded react-intl
. the least intrusive fix that's worked for me so far is to run this:
npx yarn-deduplicate --packages @types/react yarn.lock
if the resulting diff of the lockfile looks correct, go ahead and delete node_modules
, then yarn
to get fresh packages off the deduplicated lockfile.
score:24
i got the same error. i managed to fixed it by removing my '@types/react' and then installing them again.
yarn remove @types/react
yarn add --dev @types/react
score:44
this seems to be a typescript issue.
my current workaround is adding "skiplibcheck": true
to tsconfig.json
.
i want to stress that that is only a workaround and not a fix to the problem it self.
score:152
this seems te happen because yarn resolves multiple versions of a package; @types/react
in this particular case. yarn resolves @types/react
from your package.json and as a dependency of @types/react-dom
.
take the following snippet from my package.json:
"devdependencies": {
"@types/react": "^15.0.16",
"@types/react-dom": "^0.14.23"
...
}
the yarn.lock that is created after you run yarn install
contains something similar to this:
"@types/react-dom@^0.14.23":
version "0.14.23"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-0.14.23.tgz#cecfcfad754b4c2765fe5d29b81b301889ad6c2e"
dependencies:
"@types/react" "*"
"@types/react@*":
version "16.4.14"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.14.tgz#47c604c8e46ed674bbdf4aabf82b34b9041c6a04"
dependencies:
"@types/prop-types" "*"
csstype "^2.2.0"
"@types/react@^15.0.16":
version "15.6.19"
resolved "https://registry.yarnpkg.com/@types/react/-/react-15.6.19.tgz#a5de18afe65b0f29767328836b48c498a5d3a91b"
notice that @types/react-dom
depends on any version of @types/react
as indicated by "*"
. yarn resolves two versions of @types/react
: "16.4.14"
and "15.6.19"
. this results in the type conflicts you mentioned.
the solution is to add a resolutions field to your package.json to tell yarn to resolve a specific version of @types/react
. take the following sample:
"resolutions": {
"@types/react": "^15.0.16"
}
run yarn install
again. notice the change in the yarn.lock file:
"@types/react-dom@^0.14.23":
version "0.14.23"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-0.14.23.tgz#cecfcfad754b4c2765fe5d29b81b301889ad6c2e"
dependencies:
"@types/react" "*"
"@types/react@*", "@types/react@^15.0.16":
version "15.6.19"
resolved "https://registry.yarnpkg.com/@types/react/-/react-15.6.19.tgz#a5de18afe65b0f29767328836b48c498a5d3a91b"
yarn now resolves the same version "15.6.19"
for both "@types/react@*"
and "@types/react@^15.0.16"
dependencies.
i would like to know myself why this is needed. i would expect yarn to understand it can resolve dependency "@types/react" "*"
with "@types/react@^15.0.16"
instead of resolving it with the latest version of @types/react
.
Source: stackoverflow.com
Related Query
- Duplicate identifier 'LibraryManagedAttributes'
- @types/styled-components Duplicate identifier FormData
- Avoid duplicate identifier between objects and interfaces in TypeScript
- TypeScript error: Duplicate identifier 'LibraryManagedAttributes'
- React Native 0.57.1 Android Duplicate Resources
- React Native Duplicate resources
- React svg xmlns:xlink identifier expected
- ReactJS - SCRIPT1010: Expected identifier - Production build not running on IE11
- Is graphql's ID type necessary if I've set an unique identifier with dataIdFromObject in Apollo Client
- Amplify React Native - Duplicate Error using amplify add api
- toLowerCase on TextInput value is creating duplicate text if capital letter created
- How to avoid sending multiple duplicate AJAX requests in axios
- prevent duplicate objects being added to state react redux
- Duplicate ReactJS import issue when using npm link to test component before publishing as npm package
- Extract duplicate javascript code using WebPack CommonsChunkPlugin
- Removing duplicate array values and then storing them [react]
- Mixins and duplicate methods in React.js
- Avoid Duplicate Meta Description and Keywords in Next.js
- recoil: Duplicate atom key - in nextjs
- Expected an identifier and instead saw '>'
- React : Handle multiple browser(s), browser tabs to restrict duplicate operations
- Importing React: Unexpected identifier 'React'. import call expects exactly one argument."
- React Native Duplicate module naming collision
- How to prevent User from creating duplicate values using React-Select Creatable?
- Duplicate active queries in Apollo Client Devtools
- How does Apollo Client + Server handle duplicate related nodes in the same query?
- React - Uncaught SyntaxError: Identifier 'WBSAutoFillFormTypeUndetermined' has already been declared
- how to remove duplicate objects from an array in reactjs
- identifier "aa_bb" is not in camel case
- Duplicate string index signature.ts(2374)
More Query from same tag
- How to add case insensitive filtering in react-table for components content?
- Typescript error 'argument of type is not assignable to parameter of type'
- Material-UI show letter avatar when ther is no image
- Customizing my location button in airbnb/react-native-maps
- How to set default value when disabled input is true
- How to change style property on one React component without changing them all
- Why is SetState in React updating other objects in handler?
- Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED
- WebStorm: how to add jsx file type to 'File > New' list
- Mobx makeAutoObservable not binding this
- How to test useEffect combined with useDispatch hooks using jest/enzyme?
- Pragmatic approach to interface navigation on gamepad?
- react router and redux dispatch() is running from all routes once instead of only current route
- Why is onClick function call only passing one character? (ReactJs)
- webpack /src outside root directory
- Passing props in React-TypeScript
- API Request to RAPID API gives StatusCode: 401,
- React hover to show image. Hover isn't working
- What is the purpose of `beforeEach` global in Jest?
- Passing a function in props to a component
- React is very slow when I put button to every cells in hundred rows
- Download image using Axios in React?
- Function not pointing to the updated value of state variable using hooks
- How to use the custom hook on click event which contains useEffect and useReducer?
- Is there a way to spy/mock using Jest on fat arrow class instance methods for React components?
- Can I use sticky horizontal scrollbar in ANT design table?
- access to inner input element in react-select
- React Router props.match and props.history.push are undefined while using useContext
- implement an export and it's sub export in react
- Amplify AppSync doesn't upload S3Object file from client