failedtocopy
failedtocopy
  • 发布:2023-02-02 17:02
  • 更新:2023-05-29 15:15
  • 阅读:1036

vite+ts+小程序开发,安装npm包报错

分类:uni小程序sdk

package.json:
{
"name": "uni-preset-vue",
"version": "0.0.0",
"scripts": {
"dev:mp-weixin": "uni -p mp-weixin",
"dev:mp-weixin-stag": "uni build -p mp-weixin --mode staging",
"build:mp-weixin-stag": "uni build -p mp-weixin --mode staging",
"build:mp-weixin-prod": "uni build -p mp-weixin --mode production",
"type-check": "vue-tsc --noEmit"
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-app-plus": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-components": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-h5": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3061620221230002",
"vue": "^3.2.45",
"vue-i18n": "^9.1.9"
},
"devDependencies": {
"@dcloudio/types": "^3.2.7",
"@dcloudio/uni-automator": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3061620221230002",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-3061620221230002",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3061620221230002",
"@vue/tsconfig": "^0.1.3",
"typescript": "^4.9.4",
"vite": "4.0.4",
"vue-tsc": "^1.0.24",
"js-yaml": "^3.14.1"
}
}

报错信息:
While resolving: @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! Found: vite@4.0.4
npm ERR! node_modules/vite
npm ERR! peer vite@"^4.0.0" from @vitejs/plugin-legacy@3.0.2
npm ERR! node_modules/@vitejs/plugin-legacy
npm ERR! @vitejs/plugin-legacy@"^3.0.1" from @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-alpha-3061620221230002" from the root project
npm ERR! peer vite@"^4.0.0" from @vitejs/plugin-vue@4.0.0
npm ERR! node_modules/@vitejs/plugin-vue
npm ERR! @vitejs/plugin-vue@"^4.0.0" from @dcloudio/uni-app-vite@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/uni-app-vite
npm ERR! @dcloudio/uni-app-vite@"3.0.0-alpha-3061620221230002" from @dcloudio/uni-app-plus@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/uni-app-plus
npm ERR! @dcloudio/uni-app-plus@"3.0.0-alpha-3061620221230002" from the root project
npm ERR! @vitejs/plugin-vue@"^4.0.0" from @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-alpha-3061620221230002" from the root project
npm ERR! 2 more (@vitejs/plugin-vue-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite@"4.0.3" from @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-alpha-3061620221230002" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vite@4.0.3
npm ERR! node_modules/vite
npm ERR! peer vite@"4.0.3" from @dcloudio/vite-plugin-uni@3.0.0-alpha-3061620221230002
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-alpha-3061620221230002" from the root project

2023-02-02 17:02 负责人:无 分享
已邀请:
YUANRJ

YUANRJ

使用pnpm安装下

  • 聪大帅

    也是一样的,vite版本有冲突,有的是要vite3.X有的是vite4.x。 执行npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project拉下来的一样

    2023-03-10 11:58

聪大帅

聪大帅

这个是图

l***@163.com

l***@163.com

最后解决了吗,我也遇到这个问题

一顾倾人诚

一顾倾人诚

yarn

l***@163.com

l***@163.com

继续使用npm,安装时带上egacy-peer-deps参数,npm install --egacy-peer-deps

7***@qq.com

7***@qq.com

一样遇到了,vite版本不匹配,换了又报另一个依赖不匹配

要回复问题请先登录注册