How can I install vuex in a vue CLI project?

Viewed 6349

I install and create a project vue with VUE CLI. I would like to add VUEX to add a store in my app. But when I use:

npm install vuex --save-dev

I have errors:

Could not resolve dependency:peer vue@"^2.0.0" from vuex@3.6.2 node_modules/vuex vuex@"*" from the root project

How can I fix this? Should I install vue in other way?

4 Answers

There are two ways to add vuex in Vue Cli Project

1 The following documentation can help you

npm install vuex

Another one is

vue add vuex

If you have problems with the command line, you can also add vuex with the User Interface. Just type vue ui and install vuex under plugins tab in the browser window, which just opened (at port 8000)

To install the latest version you can use:

npm install vuex@next --save

As stated in the documentation, the following command can help you:

yarn add vuex
Related