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

Update README.md to reflect correct usage of "import" #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nickcmaynard
Copy link

@nickcmaynard nickcmaynard commented May 29, 2023

There are a number of issues: #281, #292, #242 which appear to be falling down on the import not working correctly.

The imports in these issues use:
import QRCode from 'qrcode'

But this results in QRCode as being undefined.

As #281 and #186 state, this import appears to work:
import * as QRCode from 'qrcode'

Ideally, the documented method would work, but it doesn't. Thus this PR updates the documentation to show the method that does work.

@mitra42
Copy link

mitra42 commented Jun 10, 2023

At the same time as doing this, it would be good to document a way to import in the browser. so that it can be used inside modules. For example
import * as QRCode from '../qrcode/build/qrcode.js'

imports fine but QRCode is a module, so for example there is no QRCode.toCanvas

Copy link

@geeky01adarsh geeky01adarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing it out, it worked for me.

@mitra42
Copy link

mitra42 commented Jun 22, 2023

For use in the browser, I moved to "qrcode-generator-es6" as I couldn't get this one to work.

My examples using that module (which failed in using this one because of the problem above) are in https://github.com/mitra42/html-element-extended in qrelementextended.js - just the display part - the detect part still has some browser compability issues I'm working on.

Note - ... not a criticism of this module, I posted my response before realizing the name of this module (node-qrcode) suggests its to run in the server under node, not in the browser.

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

Successfully merging this pull request may close these issues.

3 participants