How to convert HD wallet master key to extended key and child keys in javascript?
The base58 module is designed for Flickr; it uses a different alphabet ordering than Bitcoin, and only handles fairly small numbers not the size Bitcoin needs. For Bitcoin use bs58 module plus one other fix: the checksum is not the whole SHA256d but only the first 4 bytes, or since you store it in hex the first 8 chars:
const bs58 = require ('bs58');
... same except 
var data_with_checksum = data + sha_256_2.substring(0,8);
var result = bs58.encode(Buffer.from(data_with_checksum,'hex'));
-&gt;
xprv9s21ZrQH143K3mfksXFtCXmQBeuA4wJqhcEJKgxzocJqadRRZZZvW2quiv9XiRw9BipJgvjbGLipAH5ZT9868uA4LFwJexUaJus2EVe4FXq

However, as the bs58 page says, there is a bs58check module that combines the checksum and encode for you:
const bs58check = require ('bs58check');
... first two parts only, computing data
var result = bs58check.encode(Buffer.from(data,'hex'));
-&gt; same

And the same github user also has bip32 and bip32-utils modules that probably do the whole job for you, although the readme's are fairly limited and you'll probably need to look at the code (I didn't have time).