Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lordherald28 opened this issue Jun 26, 2022 · 10 comments
Open

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

lordherald28 opened this issue Jun 26, 2022 · 10 comments

Comments

@lordherald28
Copy link

Error Angular 14

@metafloor
Copy link
Owner

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

@lordherald28
Copy link
Author

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

@metafloor
Copy link
Owner

metafloor commented Jun 26, 2022

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().

@lordherald28
Copy link
Author

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

@metafloor
Copy link
Owner

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.

@lordherald28
Copy link
Author

lordherald28 commented Jun 27, 2022

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

@metafloor
Copy link
Owner

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.

@lordherald28
Copy link
Author

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

import bwipjs from "bwip-js";

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

@dimaveshkin
Copy link

@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?

@metafloor
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants