Home > Software engineering >  Correct update nodejs and npm
Correct update nodejs and npm

Time:04-08

i am working on nuxtjs project since node v14 version. and now node is version v16. and I'm trying to update node to version v16. but after that my nuxt project error. I'm confused, should I stick with v14 or upgrade? what is the best way to update?

CodePudding user response:

It is recommended to update to get the latest features and security updates.


To update Node.js and npm, go to nodejs.org, download, and run the installer. The Node Package Manager should automatically be installed too.

Also, don't worry about removing the previous version; the installer takes care of that too.


To update your dependencies, update the dependencies and devDependencies fields to be the latest versions. For Nuxt.js, the latest version (at the time posted) is v2.15.8.

You can also use npm-check-updates to check for updates for all of your dependencies. Run the following commands to use it (running it in your project root directory).

$ npm install -g npm-check-updates
$ ncu -u
$ npm install

ncu is the command for npm-check-updates.

Also, you can update all of your dependencies manually to have the asterisk instead of the version, as so.

{
  "dependencies": {
    "nuxt": "*"
  }
}

So, every time you run the command below, it will update the dependencies to the latest version.

$ npm install

CodePudding user response:

You can do it by installing n:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

It will install the current stable version of node.

  • Related