node-canvas error

node-canvas error
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
I tried using node-canvas with jsbarcode to process barcode from a node application but node-canvas seems to be an issue ever since I tried implementing using it.I have tried rebuilding from source yet the error still a blocker.
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
3 Replies
Leke
Leke2y ago
const express = require('express');
const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const { handleErrors } = require('../helpers');

const router = new express.Router();

// Generate Barcode
router.get('/barcode', async (req, res) => {
const { data } = req.params;

try {
if (!data) {
return res.status(404).send();
}

const canvas = createCanvas(250, 100, 'image');
JsBarcode(canvas, data, {
fontSize: 24,
fontOptions: 'bold',
mod43: true,
});
const buffer = canvas.toBuffer();

res.set('Content-Type', 'image/png');
res.status(200).send(buffer);
} catch (e) {
handleErrors(e, res);
}
});

module.exports = router;
const express = require('express');
const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const { handleErrors } = require('../helpers');

const router = new express.Router();

// Generate Barcode
router.get('/barcode', async (req, res) => {
const { data } = req.params;

try {
if (!data) {
return res.status(404).send();
}

const canvas = createCanvas(250, 100, 'image');
JsBarcode(canvas, data, {
fontSize: 24,
fontOptions: 'bold',
mod43: true,
});
const buffer = canvas.toBuffer();

res.set('Content-Type', 'image/png');
res.status(200).send(buffer);
} catch (e) {
handleErrors(e, res);
}
});

module.exports = router;
Electronic
Electronic2y ago
I'm not experience with node canvas or understand fully what your doing....but there is single bar code library that can turn text to barcode images and files and binary image data
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server