JsBarcode icon indicating copy to clipboard operation
JsBarcode copied to clipboard

getting error on require

Open varun-vivek opened this issue 4 years ago • 2 comments

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');

varun-vivek avatar Nov 26 '19 06:11 varun-vivek

This looks like a problem with your environment rather than with JsBarcode. You'd need to provide more info.

wodin avatar Mar 01 '20 16:03 wodin

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 🙂

kdgyimah avatar Apr 09 '21 02:04 kdgyimah