problem
获取开源react项目,一顿操作: npm install, npm run start
页面报错:
@types/react/index.d.ts
Duplicate identifier ‘LibraryManagedAttributes’.
reason
应该是依赖原因
solution
改为yarn安装
rm -rf node_modules
yarn install
修改配置
yarn remove @types/react-dom @types/react
yarn add -D @types/react-dom @types/react
重启
yarn run start
当使用npm安装后启动React应用出现类型定义重复错误时,通过切换到yarn,清理node_modules,重新安装并调整类型包,可以有效解决Duplicate identifier错误。此方法涉及依赖管理和类型管理,适用于前端开发中遇到的TypeScript相关问题。
1200

被折叠的 条评论
为什么被折叠?



