Home > Mobile >  Why is there an error when installing vuex?
Why is there an error when installing vuex?

Time:02-08

Tell me, I understand that there is a problem in the versions, but how to solve it?

I have tried:

npm cache clean --force commands
npm install -g npm-install-peers
npm install --legacy-peer-deps

Install with npm install --save-dev vuex@next gives me this error

Error message

My package.json file:

"name": "",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"serve:standalone": "vue-cli-service serve --mode standalone"
},
"dependencies": {
"core-js": "^3.6.5",
"devextreme": "21.2.5",
"devextreme-vue": "21.2.5",
"single-spa-vue": "^2.1.0",
"vue": "^2.6.11"
},
"devDependencies": {
"@storybook/vue": "^6.4.14",
"@vue/cli": "^4.5.15",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"node-sass": "^6.0.1",
"sass-loader": "^10",
"eslint-plugin-vue": "^6.2.2",
"vue-cli-plugin-single-spa": "~3.1.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
  "node": true
},
"extends": [
  "plugin:vue/essential",
  "eslint:recommended"
],
"parserOptions": {
  "parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
 "not dead"
]

CodePudding user response:

That is because you're trying to install Vuex@4, which is only compatible with Vue@3. However, your project is using Vue@2 instead.

You will need to decide which Vue version you want to use. Since you mentioned that you only want to use Vue2, you need to install the Vuex@3 instead:

npm install vuex@3
  •  Tags:  
  • Related