NPM, Nodejs and the VSCode IBM Blockchain Platform Add-on Woes
Tags: vscode, blockchain, npm, node
Published: 2020-05-09 16:20:37

I originally wrote this post in case someone might be having similar problems. I was trolled for putting a useless article up, so I deleted it. I was asked to repost it by someone that it did help, so for that person, and maybe the one other person who is having similar issues, here it is. Others may be lucky enough that things just work, but for others, Murphy seems to just ride our shoulders. 


I've decided to post my recent (just finished apparently) woes with an issue I encountered with the IBM Blockchain Platform add-on. I put all this in my "Base System Setup" zim wiki notebook, but after the google rabbit holes I've had to run down in order to find the answers to this, I wanted to post it immediately in the hopes it can save someone a few headaches, or worse, giving up. 


The problem started, after a complete reinstall on my laptop, and on opening VSCode. The IBM Blockchain Platform prerequisites page came up, indicating it needed NPM v6 or later. My fresh system had v5.8. I tried every normal way to update and reinstall, etc. Nothing would work. All I could think was, well if they want v6, why does it seem like it doesn't exist?! After much googling, and many different attempts that all failed,  (I made notes, lots of notes) I found what finally worked for me. I was surprised in the end that I did succeed. It reminded me of past issues following tutorials that never seem to work. Successions of these (ad nauseum) made me throw React, Vue, Svelte and many other interests to the way-side, never to be looked at again. In case it may be relevant, in this experience I'm running Linux Mint Debian Edition 4 on an older Acer Aspire (i5 with 8GB RAM). 

I pasted my notes directly:

Install NVM to install Nodejs and NPM .... I made the mistake, it seems, of installing Nodejs first, then NPM, and ran into all kinds of issues. I remembered afterward that in the past, installing NPM auto installed Node, but I don't know if it still does. I ended up using NVM.


> sudo apt recommends build-essential (which told me about installing libalgorithm-merge-perl)

> sudo apt install build-essential

> apt install --install-recommends libalgorithm-merge-perl

> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

> sudo apt install libssl-doc nodejs npm

> npm i -g npm-upgrade

> sudo reboot 


(this is necessary for npm, etc. to properly update for VSCode IBM Blockchain add-on to recognize npm version, I figured out. That was a lot of frustration!) — note to self: you will have to use NVM to change default version of Node from 14+ to 10.20.1 (uses 8.x and 10.x only) according to the add-on prerequisites.

> nvm install 10.20.1
> nvm alias default 10.20.1


Even after all this, exiting the terminal (again) allowed for only some things to register as changed, but I found I had to reboot in order for everything to be registered properly (I guess) and the add-on to recognize the version change to NPM. I never saw anything about this in any help I found. 


Of course then I saw the warning that it only worked with Node version 8.x and 10.x, so I opened a terminal and used NVM to install and make default, the highest version of 10.x, which turned out to be version 10.20.1, so all updates to that version would be included. On re-opening VSCode, the blockchain add-on took awhile to rebuild the native node modules (a long long while) but I walked away before I was tempted to assume it had hung. 


And, wonderfully, the blockchain add-on now has no prerequisites (other than adding the GO and Java options, but that's for much later on.)


Now, I can finally get things going again. And by the way, working with containers through VSCode is very nice, especially to a container newbie.  


And I have to include a few great links I recently came across in my studies.


This really helps you get your head around a few things:
https://hackernoon.com/learn-blockchains-by-building-one-117428612f46


I am really excited about this, and cannot wait to begin using it (thanks Tong (https://github.com.litong01), I really appreciate this!):
https://www.hyperledger.org/blog/2020/04/29/minifabric-a-hyperledger-fabric-quick-start-tool-with-video-guides


And I'm pretty sure I have this link somewhere else, but as it's relevant to what I'm doing:
https://hub.docker.com/r/ibmblockchain/vscode-prereqs


Hope some of this saves someone some pain. 


[Edit] I posted the link to this article on Twitter, but Twitter gave an unsafe link error, though it connects directly to my Blogger account and is safe. I'm currently waiting for Google Domains and Blogger to get their end working as I've gone over everything on my end. (Probably still something I did when stuck on stupid, but ...) 



Cheers!