1

I had node 16.15.1 installed and I need and older version (10) for another project so I installed nvm, installed node 10 and switched (nvm use 10) to that version to install the node packages for that project (lets say project B).

Now I switched to project A and executed npm run serve and it complied saying that I use node 10. I executed nvm use 16 and run again, same problem. Double checked it with node --version and it said that I use v.16 and from nvm list I got the two versions but it said that I use v.16.

Now I have uninstalled both versions and reinstalled only v.16 and it still complains about the version

> nvm ls 

16.15.1 (Currently using 64-bit executable)
> npm run serve

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

> single-stylist-website@0.1.0 serve
> vue-cli-service serve

 ERROR  You are using Node v10.15.2, but vue-cli-service requires Node ^12.0.0 || >= 14.0.0.
        Please upgrade your Node version.
> node --version

v16.15.1

Steps that I did trying to get rid of the v.10

  • I deleted all node versions from nvm folder.
  • I deleted node from control panel
  • I also restarted my pc and tried with multiple cmd window to be sure that I wasn't some problem with that cmd window

I don't understand why it won't switch to v.16 because when I switch from v.16 to v.10 it worked perfectly. Now when I tried to switch from v.10 to v.16 it got stuck on v.10 somewhere

UPDATE

package.json

{
  "name": "single-stylist-website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "engines": {
    "node" : ">=14.0.0"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "core-js": "^3.8.3",
    "npm": "^8.12.1",
    "vue": "^3.2.13",
    "vue-router": "^4.0.3",
    "vuex": "^4.0.2"
  },
  "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"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "@babel/eslint-parser"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead",
    "not ie 11"
  ]
}

I created a new project and copy pasted everything but node_modules, run npm install`` and then npm run serve``` and know everything works.

Possible cause:

I have red know the docs carefuly and saw that you need to delete node before installing nvm so I delete everything related to node, npm, nvm. Including the env variables

Nicoara
  • 318
  • 2
  • 15
  • [How can i specify the required node js version in package.json](https://stackoverflow.com/questions/29349684/how-can-i-specify-the-required-node-js-version-in-package-json) – Dave Meehan Jun 03 '22 at 10:02
  • No success. I have added this line in package.json "engines": { "node" : ">=14.0.0" }, And after running npm run serve I got the same error "you are using node v10 and node >=v14 required" but again I tested with nvm ls to see what node version uses but it sad that it uses v.16 – Nicoara Jun 03 '22 at 11:04
  • Please can you add your package.json to the original post. `nvm` is going to report the installed and active versions, but when you run a script with `npm` it should refer to the `engines` and use the specified version. Check the [docs](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#engines) as it also specified the `npm` version and that might be tripping you up. – Dave Meehan Jun 03 '22 at 11:40

0 Answers0