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

ReferenceError: atob is not defined #59

Closed
MigueloAtla opened this issue Apr 3, 2022 · 5 comments · Fixed by #62
Closed

ReferenceError: atob is not defined #59

MigueloAtla opened this issue Apr 3, 2022 · 5 comments · Fixed by #62
Labels
bug Something isn't working

Comments

@MigueloAtla
Copy link

Not able to use the package.
I'm getting this error only importing from @pdfme/generator.

@hand-dot
Copy link
Collaborator

hand-dot commented Apr 3, 2022

Hi @MigueloAtla

Please check #57 (comment)

If you can create a minimal reproduction environment, I'll check that.

@HaeusslerAdrian
Copy link

Hi @hand-dot,

I have the same issue and I created the minimal app
https://github.com/adresta/pdfme_issue

I also found out that this issue exists on node14, but it will go away when upgrading to node16

@hand-dot
Copy link
Collaborator

hand-dot commented Apr 8, 2022

@HaeusslerAdrian

Thank you create a minimal app, I'll check that repo.

@hand-dot hand-dot added the bug Something isn't working label Apr 8, 2022
@hand-dot
Copy link
Collaborator

@mbiegert
Copy link
Contributor

To sum this up (and for anyone that cannot read japanese): Node.js 16 adds a web API compatibility layer providing a global atob (while discouraging using it in new code) which is a simple alias to Buffer.from(data, "base64").
See https://nodejs.org/dist/latest-v16.x/docs/api/globals.html#atobdata.

The linked reference suggests installing a package "atob" on Node.js < 15 and adding it to the global, based on the documentation linked above we can add that alias ourselves instead of adding an additional package:

if (!global.atob) {
    global.atob = (data) => Buffer.from(data, "base64");
}

To close this issue there should probably be some kind of note added to the readme as you probably want to continue support for Node.js 14 while it's still in maintenance mode: https://nodejs.org/en/about/releases/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants