Upgrading Node.js to latest version

2019-01-03 03:51发布

So, I have Node.js installed and now when I tried to install Mongoosejs I got an error telling me that I don't have the needed version of Node.js (I have v0.4.11 and v0.4.12 is needed).

How can I upgrade to this version? I suppose I just could install it again with the latest version, but I don't want to do it before I'm sure that my project folders in the folder "node" won't be deleted.

29条回答
叼着烟拽天下
2楼-- · 2019-01-03 04:09

All platforms (Windows, Mac & Linux)

Just go to nodejs.org and download the latest installer. It couldn't be any simpler honestly, and without involvement of any third-party stuff. It only takes a minute and does not require you to restart anything or clean out caches, etc.

I've done it via npm a few times before and have run into a few issues. Like for example with the n-package not using the latest stable release.

查看更多
Ridiculous、
3楼-- · 2019-01-03 04:10

just try this on your terminal :

nvm install node --reinstall-packages-from=node

it should do the trick.

later, run node --version to check the version that you have.

查看更多
我命由我不由天
4楼-- · 2019-01-03 04:14

Using brew and nvm on Mac OSX:

If you're not using nvm, first uninstall nodejs. Then install Homebrew if not already installed. Then install nvm and node:

brew install nvm
nvm ls-remote    # find the version you want
nvm install v7.10.0
nvm alias default v7.10.0    # set default node version on a shell

You can now easily switch node versions when needed.

Bonus: If you see a "tar: invalid option" error when using nvm, brew install gnu-tar and follow the instructions brew gives you to set your PATH.

查看更多
戒情不戒烟
5楼-- · 2019-01-03 04:16

Linux/Mac:

The module n makes version-management easy:

sudo npm install n -g

For the latest stable version:

sudo n stable

For the latest version:

sudo n latest

Windows:

just reinstall node from the .msi in Windows from the node website.

查看更多
\"骚年 ilove
6楼-- · 2019-01-03 04:16

via npm:

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

and also you can specify a desired version:

# n 0.8.21

reference

查看更多
戒情不戒烟
7楼-- · 2019-01-03 04:17

Upgrading node.js to the latest version on Windows

  1. Install chocolatey if you haven't already: Installing Chocolatey

  2. From the command prompt, type

    cup nodejs

(which is equivalent to typing choco upgrade nodejs -- assumes you already have node installed)

NOTE: You may need to run cinst nodejs.install for chocolatey to register your existing installation. (thanks for the comment, @mikecheel)


Installing node.js on Windows

If you have never installed node, you can use chocolatey to do that as well. Install chocolatey (see step 1 above). Then from a command prompt, type:

cinst nodejs.install

Chocolatey Gallery Node JS (Install)


Installing a specific version of node on Windows with chocolatey

cinst nodejs.install -Version 0.10.26

查看更多
登录 后发表回答