Skip to content

TypeError: import_qrcode.default.toBuffer is not a function when running in Cloudflare Workers #376

Description

@vladinator1000

Hi there, it seems like the library doesn't work on Cloudflare even with the compatibility flags in wrangler.toml:
compatibility_flags = ["nodejs_compat_v2"]

Steps to reproduce:

  1. Clone this repo: https://github.com/vladinator1000/cf-qrcode
  2. Run npm start
  3. Go to localhost:8787

I can see that toBuffer is clearly exported from https://github.com/soldair/node-qrcode/blob/master/lib/server.js#L106
I wonder if the issue is due to the bundling process. When I enumerate the package keys like this

import QRCode from 'qrcode';

export default {
	async fetch(request, env, ctx): Promise<Response> {
		return new Response(Object.keys(QRCode));
	},
} satisfies ExportedHandler<Env>;

I get

create,toCanvas,toDataURL,toString

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions