generating a zprv from a base58 rootKey with bitcoinjs-lib var bitcoin = require('bitcoinjs-lib');
let bip32 = require('bip32');

let rootKey = 'xprv9s21ZrQH143K32CfqoCQHtbKiEb5BqFazXX6jCtNCnuty3gUjxS4CsXWi9rcNyHdjDVPiC6P1bnyEZr2ioouRq56h6HAdwejeTty1BsSEtL'
const node = bip32.fromBase58(rootKey, bitcoin.networks.bitcoin);

//legacy account extended private key
console.log(&quot;LEGACY: &quot; + node.derivePath(&quot;m/44'/0'/0&quot;).toBase58())
//xprv9y7nL2k2diLdA9bmop94K8Pec2WdL998PLdvTraxj5jiQ36gnLmhVJG4bY8FzgqZPaBM5HDBi9sgRK1ZCi14n5j4Pk1o6d3j4Y6T9NS4nA6
(works as expected)


//segwit account extended private key
//trying to get a segwit extended private key (zprv) using the same inputs as above.

I want to get a segwit/bech32 extended private key using the same root key as above. How can I do this using bitcoinjs-lib? BIP84 only works for mnemonics IIRC.
Your xprv already has the derivation path &quot;baked in&quot; so even if you were to just convert to zprv it will still be under the old m44/ deriv path. Also you can't go from xprv to HD seed. So to change from an xprv to a zprv or yprv you need to start with the HD seed, then declare your derivePath(&quot;m84'/...&quot;,&quot;m49/'/... etc), then you can create an extended public key. Then you'll have to convert to yprv, zprv, ypub, etc...
Example uses bitcoinjs-lib v3.3.2
function seedToXpub(seed, deriv, account){
   var root = bitcoin.HDNode.fromSeedHex(seed);
   var acct = root.derivePath(&quot;m/&quot;+deriv+&quot;'/0'/&quot;+account+&quot;'&quot;);
   var xpub = acct.neutered().toBase58();
   return{
       xpub
   }
}

function seedToXprv(seed, deriv, account){
   var root = bitcoin.HDNode.fromSeedHex(seed);
   var acct = root.derivePath(&quot;m/&quot;+deriv+&quot;'/0'/&quot;+account+&quot;'&quot;);
   var xprv = acct.toBase58();
   return{
       xprv
   }
}

function convertXpub(xpub,target){
    //source script for converter https://github.com/jlopp/xpub-converter/blob/master/js/xpubConvert.js
    const prefixes = new Map(
  [
    ['xpub', '0488b21e'],
    ['ypub', '049d7cb2'],
    ['Ypub', '0295b43f'],
    ['zpub', '04b24746'],
    ['Zpub', '02aa7ed3'],
      ['xprv', '0488ade4'],
      ['yprv', '049d7878'],
      ['zprv', '04b2430c']
  ]
  );
    
  xpub = xpub.trim();

  try {
    var data = b58.decode(xpub);
    data = data.slice(4);
    data = Buffer.concat([Buffer.from(prefixes.get(target),'hex'), data]);
    return b58.encode(data);
  } catch (err) {
    return &quot;Invalid extended public key! Please double check that you didn't accidentally paste extra data.&quot;;
  }    
}

var mySeed = &quot;114259550292e14ca462e5202875f987fa3c93300306417c8b62de591710e4b34340a9bcdf8241ebbe83cf3cdf428c2f32973c9db68e247ce623fd73b9bd1fb2&quot;;
var extPriv = seedToXprv(mySeed,84,0);
var zprv = convertXpub(extPriv,&quot;zprv&quot;); 

//zprvAcihK1ERNzUfX6zh3v8weMVw5s8Y2xkmjdEfeFF3v9X2jbDf9iJ4vS5t4Po6Jhwsjkzjz1TddTENc5dPVsVFyMZPzWz8Kskci6wkYSmuhup