i want to install vue-router but some errors occurs
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   vue@"^2.5.11" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^3.2.0" from [email protected]
npm ERR! node_modules/vue-router
npm ERR!   vue-router@"4" 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 C:\Users\Peyman\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Peyman\AppData\Local\npm-cache\_logs\2022-05-31T07_48_48_170Z-debug-0.log
                The problem is you have incompatible versions of vue and vue-router.
vue@2 requires vue-router@3vue@3 requires vue-router@4The error message indicates you have [email protected], and you're trying to install [email protected]. Note that npm install -S vue-router (without a version specifier) defaults to the latest version, which is currently 4.0.15.
Don't use the --force or --legacy-peer-deps npm flags that are suggested in the error message because that would only install incompatible packages that would result in a runtime error.
A quick fix is to install vue-router@3:
npm install -S vue-router@3
Or you can upgrade to Vue 3, which requires uninstalling vue-template-compiler (the template compiler for Vue 2) and installing @vue/compiler-sfc (the template compiler for Vue 3):
npm uninstall -S vue-template-compiler
npm install -S vue@3 @vue/compiler-sfc
                        you can add by using plugin also using vue-cli.
try vue add router
btw use can install vuetify and eslint and many more things using vue add vuetify and vue add eslint
you can refer this: https://cli.vuejs.org/guide/plugins-and-presets.html#plugins
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With