执行`npm i -D @uni-helper/uni-app-types`命令报错npm error ERESOLVE unable to resolve dependency tree

问题现象

已经使用npx degit dcloudio/uni-preset-vue#vite-ts uni-app-vue3-ts命令创建了一个项目。

再执行npm i -D @uni-helper/uni-app-types命令,目的是为 Vue v3 uni-app 组件提供 TypeScript 类型,但报错:
在这里插入图片描述

D:\temp\HBuilderProjects\uni-app-vue3-ts>npm i -D @uni-helper/uni-app-types
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error
npm error While resolving: uni-preset-vue@0.0.0
npm error While resolving: uni-preset-vue@0.0.0
npm error Found: typescript@4.9.5
npm error Found: typescript@4.9.5
npm error node_modules/typescript
npm error   dev typescript@"^4.9.4" from the root project
npm error
npm error Could not resolve dependency:
npm error   dev typescript@"^4.9.4" from the root project
npm error
npm error
npm error Could not resolve dependency:
npm error peer typescript@"^5.0.0" from @uni-helper/uni-app-types@1.0.0-alpha.4
npm error peer typescript@"^5.0.0" from @uni-helper/uni-app-types@1.0.0-alpha.4
npm error node_modules/@uni-helper/uni-app-types
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-eresolve-report.txt

npm error A complete log of this run can be found in: D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-debug-0.log

npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-eresolve-report.txt

npm error A complete log of this run can be found in: D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-debug-0.log
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-eresolve-report.txt

npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-eresolve-report.txt
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error   dev @uni-helper/uni-app-types@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-eresolve-report.txt

npm error A complete log of this run can be found in: D:\npm_repo\npm-cache\_logs\2024-09-11T11_58_17_606Z-debug-0.log

D:\temp\HBuilderProjects\uni-app-vue3-ts>

问题原因

npx degit dcloudio/uni-preset-vue#vite-ts 这个命令下载的模版中typescript版本低了,而@uni-helper/uni-app-types 要求v5 版本:
在这里插入图片描述

https://uni-typed.netlify.app/guide/uni-app-types.html#%E5%B7%B2%E6%9C%89%E9%A1%B9%E7%9B%AE
在这里插入图片描述

问题解决

@uni-helper/uni-app-types 官网的说明:
https://uni-typed.netlify.app/guide/uni-app-types.html#%E5%B7%B2%E6%9C%89%E9%A1%B9%E7%9B%AE
在这里插入图片描述

将项目package.json文件中"typescript": "^4.9.5",这句话删掉:
在这里插入图片描述

然后执行npm install -D typescript来安装新的版本:
在这里插入图片描述

安装完后,typescript已经是v5版本:
在这里插入图片描述

现在执行npm i -D @uni-helper/uni-app-types
在这里插入图片描述

安装完成后,package.json文件中更新了依赖:
在这里插入图片描述

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值