JsBarcode
JsBarcode copied to clipboard
getting error on require
var JsBarcode = require('jsbarcode'); const { createCanvas } = require('canvas');
const canvas = createCanvas(0, 0);
// create a bar code with the number/text I want and populate the canvas with it..
JsBarcode(canvas, '123456');
Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node
and then add node
to the types field in your tsconfig.
var JsBarcode = require('jsbarcode');
~~~~~~~
src/app/app.component.ts:21:30 - error TS2591: Cannot find name 'require'. Do you need to install type definitions for node? Try npm i @types/node
and then add node
to the types field in your tsconfig.
const { createCanvas } = require('canvas');
This looks like a problem with your environment rather than with JsBarcode. You'd need to provide more info.
This is related to typescript. You may want to check this out for a fix: https://stackoverflow.com/questions/31173738/typescript-getting-error-ts2304-cannot-find-name-require
Then proceed to close this issue 🙂