How can I generate QR images in Node.js without canvas?

CherryNerd picture CherryNerd · Mar 16, 2015 · Viewed 17.9k times · Source

I'm building a website for a client in Node.js and I need to generate QR-codes or Barcodes for the ticket system.

I've found a few modules, but all of them need an install like canvas, one way or another.

I'm on a shared hosting package and my host does not allow me to install any such packages, unless I upgrade to a VPS or dedicated server (which I do not have the money for).

Does any of you know how I can pull this off in Node.js or do I need to put up a subdomain for generating the QR in PHP or front-end generating (which I do not prefer AT ALL)?

Currently using:

  • Node.js
  • Express.js
  • Angular.js

Modules found:

Answer

Balaji L picture Balaji L · Jul 16, 2017

Have a look over this code:

var qr = require('qr-image');  
var express = require('express');

var app = express();

app.get('/', function(req, res) {  
  var code = qr.image(new Date().toString(), { type: 'svg' });
  res.type('svg');
  code.pipe(res);
});

app.listen(3000);

visit npm-qr-image