You can use the chilkat library. The pfx library is free.
Load the appropriate library found at https://www.chilkatsoft.com/nodejs.asp:
var os = require('os');
if (os.platform() == 'win32') {
var chilkat = require('chilkat_node10_win32');
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('chilkat_node10_arm');
} else if (os.arch() == 'x86') {
var chilkat = require('chilkat_node10_linux32');
} else {
var chilkat = require('chilkat_node10_linux64');
}
} else if (os.platform() == 'darwin') {
var chilkat = require('chilkat_node10_macosx');
}
Use the following code to produce a Pfx File:
var pfx = new chilkat.Pfx();
var privKey = new chilkat.PrivateKey();
var cert = new chilkat.Cert();
cert.LoadFromFile(publicKeyPath);
privKey.LoadPemFile(privateKeyPath, PASSWORD_PKEY);
pfx.AddPrivateKey(privKey,certChain);
pfx.ToFile("pfxPassword","sample.pfx");