Upgrading Node.js to latest version
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.
Linux/Mac:
The module n
makes version-management easy:
sudo npm install n -g
sudo n 0.12.2
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.
2018 Solution Without sudo
!
The Current/Stable "LTS" version of node is 8.10.0 ( 2018-03-11 ) see: nodejs.org for latest.
Step 1 - Get NVM (Node Version Manger)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
If you're curious about the installation command read the source code
... its been reviewed by several security experts
Step 2 - Install the version of node.js you need
Once you've got NVM you can install a specific version of Node.js using the nvm command:
nvm install v8.10.0
Note : you may need to close & re-open your terminal window for nvm
command to be available.
You should expect to see something like this in your terminal:
Now using node v8.10.0
Step 3 - Enjoy the rest of your day!
Yes, it's that easy and didn't require sudo
!
Now please Upvote this (so others can avoid sudo
-installing things!)
and have a lovely day writing node.js code!
Microsoft Windows User? See: https://github.com/coreybutler/nvm-windows
tl;dr
Review of the node mailing list indicates that using NVM (Node Version Manager) is the preferred way to manage your nodejs versioning/upgrading. see: github.com/creationix/nvm
NVM by Tim Caswell (& friends) is "better" than N from visionmedia (TJ Holowaychuk) github.com/visionmedia/n because the verbose commands mean is much easier to keep track of what you are doing in your Terminal/SSH Log. Its also faster, saves kittens by not requiring sudo
and is used by the team at liftsecurity.io the node.js security experts !
Also worth noting: NVM has almost three times as many GitHub Stars as N ( 22896 vs 8040 ). That's usually - but not always - a sign of a better module... feel free to correct if you have evidence of otherwise ...
PS this may be a dupe of How can I uninstall or upgrade my old node.js version?
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
链接地址: http://www.djcxy.com/p/20358.html上一篇: 在进行次要升级后无法卸载组件
下一篇: 将Node.js升级到最新版本