DEV Community

Kelvin Thompson
Kelvin Thompson

Posted on

The Nodejs Update War (module 'n' ?!)

This originally appeared in my blog post https://www.redeving.dev/2020/06/the-nodejs-update-war-module-n.html

In my foray into blockchain (distributed ledger) development, I've discovered only mayhem. Another wild west frontier, so to speak. While this cultivates innovation and experimentation, when it comes to learning, there is a lot of flotsam to wade through.

It's easy to become distracted by the sheer mass and variety that comprises the waterfall of what's out there, especially if you touch the turmoil of crypto currencies. Now personally, I'm not very interested in the currency side of things. I don't have the luxury of playing with speculation and supporting other peoples bank accounts. And it distracts from the real world aspects of the distributed ledgers. And don't get me started on the digital wallet rabbit holes! I'd make one myself so I could trust it, but that's still out of my range at this time.

There's a huge, bewildering amount of variety to the world of blockchain development. There are various ways to move into the field, via game assets, for instance, but even though one of my careers was a 3D artist and animator, I've just never had the time for actually playing games, so my interest in that aspect is too narrowly focused to be of use in this regard. Then again, maybe having that slight separation of interests would help. I have feelers going that way too.

If you aim corporate, you can go with many, such as IBM with their Fabric and other cross-chain developments which is very exciting; but having a fair bit of corporate experience, these avenues can be more restrictive. The prospect of "Vendor-Lockin" looms.

Then, of course, the development environment. Seems usually over complicated like most these days. Especially with those wallets. I want something, no, need something, more agnostic.

But, this isn't an endorsement of any platform or smart contract language, like DAML or Solidity (HyperLedger alone has 6 or more languages, including DAML, that it works with at this time!) I am investigating DAML, but in the process, ran into, AGAIN, the Nodejs version battle. I called it a war in the headline because I've encountered this so many times, and being unable to find useful answers is one of the many reasons I have been turned off by Node in general, as useful as it may be. When you try to use tutorials and can't for the life of you get Node to update beyond a certain point, you can't move. Delete tut and move on. Rinse repeat, delete node!

However, this time I found a couple of tidbits that actually worked!! Oh Joy!! Only slight sarcasm.

So, I wanted to install DAML and it's SDK from daml.com. It's only supported IDE is vsCode, so no worries there. It also requires Yarn, which has caused me issues in the past, but okay. And Nodejs. Okay. I've added the links to some of the information that led to this working (many thanks!) In the past I've managed to get Node to update to version 10, but a lot of things don't seem to work with that low a version, at least from what I've found. Oh yeah, I'm running Linux Mint's Debian Edition v4.

DAML installed just fine:

curl -sSL https://get.daml.com/ | sh
If prompted, add ~/.daml/bin to your PATH.

Yarn installed fine too (nice!):
from: https://classic.yarnpkg.com/en/docs/install/#debian-stable

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
yarn --version (test the install)

Then of course, Node. The following was supposed to update to the current v14:
from: https://github.com/nodesource/distributions/blob/master/README.md#deb

sudo curl -sL https://deb.nodesource.com/setup_14.x | bash -
sudo apt update && sudo apt install -y nodejs && sudo apt install yarn

This however, only updated node to version 10 for some reason (aarrggghh!!), which as stated, is not supported by most of the things I'm doing. This is usually the point where my cat sees me smacking my head with his catnip fish.

This! This is the key! I have never come across this information before, but I really wish I had!

from: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

"Use n module from npm in order to upgrade node."

I've never heard of this module. Sigh, but okay. First, I had to install npm!

sudo apt install npm -y (this took awhile!)

Then, to update node properly to v14:

sudo npm cache clean -f (it will scream about not supporting node v10, ignore)
sudo npm install -g n
sudo n stable

This upgraded node to version 12 (sigh, Really??), almost there!

To upgrade to latest version (and not current stable) version:

sudo n latest

Exit terminal. Open terminal.

node --version (test install)
v14.4.0

Yeah! Finally, for the first time ever, my version of node is the latest. Weird.

Top comments (2)

Collapse
 
preciouschicken profile image
Precious Chicken

I always install node using the 'node version manager' (nvm). Although it seems the longer way round, it just seems to solve lots of problems that crop up later if you install it directly.

There's some useful instructions as to how to do this on StackOverflow.

Collapse
 
redeving profile image
Kelvin Thompson

Thanks. Yeah, a lot of the things I found there & other places just didn't work. But eventually... this did, for me anyways! Cheers!