0

I want to install vuex in vue2 but I got an error I've tried with multiple commends lines

  1. npm install vuex --save

  2. npm install vuex@next --save

even though I've changed the expected node version then I got these errors

$ npm install vuex@3 --save
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/khawar/.npm/_logs/2022-09-27T06_25_55_644Z-debug.log

// pakage.json file

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
{
  "name": "online-reporting-system",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.8.3",
    "firebase": "^9.9.4",
    "vee-validate": "^3.4.14",
    "vue": "^2.6.14",
    "vue-router": "^3.5.1",
    "vuetify": "^2.6.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.16",
    "@babel/eslint-parser": "^7.12.16",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "node-sass": "^7.0.1",
    "sass": "~1.32.0",
    "sass-loader": "^10.3.1",
    "style-loader": "^3.3.1",
    "vue-cli-plugin-vuetify": "~2.5.5",
    "vue-template-compiler": "^2.6.14",
    "vuetify-loader": "^1.7.0"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

5
  • The error says, that fsevents doesn't support Linux. Also, what version of vuex do you try to use? Commented Sep 27, 2022 at 6:52
  • I've tried vuex@3 version Commented Sep 27, 2022 at 7:01
  • How did you changed the node version? What version did you have back in the day (when the project started)? Also, do you have a public repo for that so we can try to see what is not working on your side? Commented Sep 27, 2022 at 7:14
  • currently, I switch to node version 14.17.0 when the previous version was not supported it's V14.16.0. By using nvm I used to change the node version Commented Sep 27, 2022 at 8:12
  • nvm is great indeed, as for the version itself, the only viable stable one as of right now is v16, v14 is dead. Commented Sep 27, 2022 at 8:21

2 Answers 2

1

You can also try this hope this helps, this is a Vue CLI command through which you add many vue plugins as shown below in this screenshot. The benefit of using this command is that it will also generate the boilerplate code needed to make that plugin work in conjunction with vue.

enter image description here

vue add vuex
Sign up to request clarification or add additional context in comments.

3 Comments

Hi, please add a little bit of context on what this command is doing, where do it come from etc...so that OP can understand what it does.
Finally, I installed it. I switch to the node's previous version v14.16.0 by using this command line npm install vuex@3 --save
Thanks for the update, I also recommend committing before such command because you never know what could happen when you code get's edited by a CLI (bugs can happen).
0

Using nvm to rollback to Node v14.16.0 allowed OP to then use

npm install vuex@3

to successfully install Vuex to the Vue 2 project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.