const bwipjs = require('bwip-js');
const pngFromBase64 = (data) => `data:image/png;base64,${data}`;
bwipjs.toBuffer({
bcid: 'code128', // Barcode type
text: '0123456789', // Text to encode
scale: 6, // 6x scaling factor
textxalign: 'center', // Always good to set this
}, (err, data) => {
if (err) {
throw err;
}
const bufferBase64 = data.toString('base64');
const img = `<img src="${pngFromBase64(bufferBase64)}" />`;
console.log(img);
});