bwip-js icon indicating copy to clipboard operation
bwip-js copied to clipboard

(imported as 'toCanvas') was not found in 'bwip-js'

Open lordherald28 opened this issue 3 years ago • 10 comments

Error Angular 14

lordherald28 avatar Jun 26 '22 04:06 lordherald28

No way to understand what is wrong since you provided nothing in terms of example code or how to replicate....

metafloor avatar Jun 26 '22 17:06 metafloor

hola, cuando intentento utilizar la libreria en Angular 14, salta este error: error con libreria codebar

lordherald28 avatar Jun 26 '22 18:06 lordherald28

Based on the extended error message, you are using a named import. The toCanvas() is part of the default exports from bwip-js. See the README at Browser ES6 Module Usage and call as bwipjs.toCanvas().

metafloor avatar Jun 26 '22 22:06 metafloor

hello, I read and performed the documentation steps, but the same error follows, is this library compatible with angular v14?

lordherald28 avatar Jun 27 '22 01:06 lordherald28

Do you understand the difference between default and named imports? Use: import bwipjs from 'bwip-js'; Do not put curly braces around anything in the import statement. Then invoke as bwipjs.toCanvas(). It would save a lot of time if you just post your code rather than me trying to guess what you are doing wrong.

metafloor avatar Jun 27 '22 02:06 metafloor

Me funciono, el problema era el siguiente: export = BwipJs; y me mostraba el siguiente error: 99 export = BwipJs; ~~~~~~~~~~~~~~~~ This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag. entonces cambie esto export = BwipJs por export default BwipJS en el index.d.ts del bwip-js y funciono a la perfeccion. Disculpa por las molestias ocaciondas y gracias el buen trabajo que usted hace. XD

lordherald28 avatar Jun 27 '22 03:06 lordherald28

Show your code! Including the import statement. I cannot help you any further without it. The screen capture you posted does not show the import statement.

metafloor avatar Jun 27 '22 03:06 metafloor

import { Component, OnInit } from '@angular/core';

import bwipjs from "bwip-js";

de todas formas, me funciona, cuando realice el cambio.

lordherald28 avatar Jun 27 '22 05:06 lordherald28

@metafloor Hi!

Why does toCanvas have to be part of the default export and not a separate method? Is it possible to import it separately to reduce bundle size?

dimaveshkin avatar Feb 06 '23 14:02 dimaveshkin

toCansas() is a generic method and links to all exports in BWIPP. That is why we have a separate named export for each encoder.

metafloor avatar Feb 06 '23 14:02 metafloor