0

title says it all. I have been using nodejs with npm for while now and it has been working fine, but I went to check the version and noticed it was an older one. Nodejs - version 8.10.0 and npm - version 3.5.2. I know there are more recent versions of each and like I said I went to download the new version of Nodejs and I got it. I have the path set up to its location in my Environment Variable. I'm not sure what I'm missing. Would love any help.

Edit: Forgot to mention on my original post that I am on Windows.

Edit2: So I was looking at it more and I am using the Ubuntu Bash Shell on muy windows computer. Whenever I check the version in the normal Windows Command Prompt it displays the right version, but when I check it in the Bash shell it is wrong. Any ideas why this happens?

mtibo
  • 61
  • 1
  • 2
  • 7

3 Answers3

0

The Node Version Manager. You can find it at https://github.com/coreybutler/nvm-windows

It allows you to easily install and manage multiple versions of node. Here's a snippet from the help:

Usage:

nvm install <version>       Download and install a <version>

nvm use <version>            Modify PATH to use <version>

 nvm ls                             List versions (installed versions)

install and Usage:

nvm install 6.14.4 # or 10.10.0, 8.9.1, etc

and then

nvm use 6.14.4
The Dead Man
  • 6,258
  • 28
  • 111
  • 193
  • Thanks for the answer, but I found my own solution to it. It seems I needed to upgrade my WSL from 1 to 2. – mtibo Jun 11 '20 at 17:01
0

So, I was able to solve my own issue These two links were very important for solving my issue:

E: Unable to locate package npm

https://learn.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2

So basically after uninstalling nodejs I went and tried uninstalling and reinstalling my Ubuntu Bash shell. Once I had the Bash shell set up again I tried running the commands listed in the stackoverflow post I have listed above. (note: When you run the curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - line you need to adjust the "setup" version to 14.x) When I ran all the commands I was able to get my npm version up-to-date, but my nodejs was still being stuck at version 10.x. I tried running the install again on nodejs and thats when I noticed an error reading gpg: can't connect to the agent: IPC connect call failed I did some research on this error and foudn out my WSL1 would not allow it to update to the most recent version. Thats how I found my way to the Microsoft page that led to me needing to update my version of Windows to 1909 and then installing WSL2 through Power Shell. Everything is now up-to-date and working!

mtibo
  • 61
  • 1
  • 2
  • 7
-1

You could Uninstall both versions and reinstall the newer version. That should do it

Or better still download the NVM and follow the instructions from here

https://blog.logrocket.com/switching-between-node-versions-during-development/
  • I went ahead and deleted it, and as I said in my post the two different versions were showing depending if I was in the Windows Command Prompt or the Bash Shell. Once uninstalled the Windows command prompt could no longer find a version, while the Bash shell still have version 8.10 showing. – mtibo Jun 10 '20 at 22:46
  • That is because it's not completely removed. Use the following code. :~ myusername$ type node node is /Users/myusername/.nvm/v0.10.48/bin/node Subsequently, after deleting that folder, Node will be completely removed from my system. Then you can install the newer version You have to delete all node and node_module folders that you can find within /usr/ to make sure - and I would suggest that anyone attempting this also do the same. – steven oloto Jun 11 '20 at 08:45