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.
Windows 10
Open CMD in folder
C:\Program Files\nodejs\node_modules
and typenpm i npm
2018 Solution Without
sudo
!The Current/Stable "LTS" version of node is 10.13.0 (2018-11-01) see: nodejs.org for latest.
Step 1 - Get NVM (Node Version Manger)
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
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 v10.13.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 v10.13.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!
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 ...
P.S. this may be a dupe of How can I uninstall or upgrade my old node.js version?
There is good explanation for linux users how to update node version step by step. P.S type instead of
sudo n stable
sudo n latest
for receive latest node version.If you receive following error
You have just rebuilt npm by the following command
npm rebuild
it should fix the problem.For Ubuntu
Install the nvm (Node Version Manager) using the below command
To install or update nvm, one can use the install script using cURL:
or Wget:
check if nvm is already installed
To install or update node, run below command:
To check the list of node version available to the system or currently running for the system, run the below command:
check the node version:
You don't need to worry about an upgrading process.
You can just install the newest version using the official documentation as if you didn't have it installed and it will work like a charm. > https://nodejs.org/en/download/package-manager/ ;)
If Node install script doesn't work for you (it didn't for me), here's the solution to update Node Js in Debian Jessie, taken from the reply from Thomas Ward at askubuntu.com (Thanks, buddy!).
1.- Create a new file:
/etc/apt/sources.list.d/nodesource.list
You'll need to create this file with sudo, but when you create the file, put this inside it:
Then, save the file. (replace node_9.x with the desired version)
2.- Download the GPG Signing Key from Nodesource for the repository. Otherwise, you may get
NO_PUBKEY
errors withapt-get update
:3.- Manually run
sudo apt-get update
.This refreshes the data from the nodesource repo so apt knows a newer version exists.
If you get a NO_PUBKEY GPG error, then go back to Step 2
4.- Check
apt-cache policy nodejs
output.This is not done by the script, but you want to make sure you see an entry that says something like this in the output:
If you do not see entries like this, and only see 0.10.29, start over. Otherwise, proceed.
5.- Install the nodejs binary. Now that you have confirmed 9.x is available on your system, you can install it:
sudo apt-get install nodejs
nodejs -v
should now show v9.2 or similar on output (as long as it starts with v9. you're on version 9 then).