Building the merkle root from transactions in a template block
I'm much closer now I hope this helps someone else trying to do this!

REQUIREMENTS:

NPM bitcoin bitcoin-js merkle-lib


CODE:

client.getBlockTemplate( function(error, template) {
    if (error) return console.log(error);
    txhashes = template.transactions.map(function(tx){ return Buffer.from(tx.txid, 'hex').reverse() });
    merkleRoot = fastMerkleRoot(txhashes, bcrypto.hash256);
    console.log(merkleRoot);
)};


The result is in a Buffer and I'm having trouble converting it to hex.