无法直接导入pinia,会报错。然后我自己想安装pinia 运行 npm install pinia安装会报错,提示与vue依赖版本冲突。使用的是官方v3+ts的创建方式。
环境:
nodejs: v18.12.0
vue: 3.4.21
vite: 5.2.8
此为报错信息:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: uni-preset-vue@0.0.0
npm ERR! Found: vue@3.4.21
npm ERR! node_modules/vue
npm ERR! peer vue@"^3.2.25" from @vitejs/plugin-vue@5.0.5
npm ERR! node_modules/@vitejs/plugin-vue
npm ERR! @vitejs/plugin-vue@"^5.0.4" from @dcloudio/uni-app-vite@3.0.0-4010520240507001
npm ERR! node_modules/@dcloudio/uni-app-vite
npm ERR! @dcloudio/uni-app-vite@"3.0.0-4010520240507001" from @dcloudio/uni-app-plus@3.0.0-4010520240507001
npm ERR! node_modules/@dcloudio/uni-app-plus
npm ERR! @dcloudio/uni-app-plus@"3.0.0-4010520240507001" from the root project
npm ERR! @vitejs/plugin-vue@"^5.0.4" from @dcloudio/vite-plugin-uni@3.0.0-4010520240507001
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-4010520240507001" from the root project
npm ERR! peer vue@"^3.0.0" from @vitejs/plugin-vue-jsx@3.1.0
npm ERR! node_modules/@vitejs/plugin-vue-jsx
npm ERR! @vitejs/plugin-vue-jsx@"^3.1.0" from @dcloudio/vite-plugin-uni@3.0.0-4010520240507001
npm ERR! node_modules/@dcloudio/vite-plugin-uni
npm ERR! dev @dcloudio/vite-plugin-uni@"3.0.0-4010520240507001" from the root project
npm ERR! 4 more (@vue/server-renderer, vue-i18n, vue-router, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! pinia@"2.1.7" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vue@3.4.31
npm ERR! node_modules/vue
npm ERR! peer vue@">= 2.5 < 2.7" from @vue/composition-api@1.7.2
npm ERR! node_modules/@vue/composition-api
npm ERR! peerOptional @vue/composition-api@"^1.4.0" from pinia@2.1.7
npm ERR! node_modules/pinia
npm ERR! pinia@"2.1.7" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/tanuoxi/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/tanuoxi/.npm/_logs/2024-07-03T03_23_36_814Z-debug-0.log
z***@126.com
升级vue后,安装pinia成功,回复一下,表示感谢
2024-08-12 18:45