auth-app.js: atob is not defined when building with target: Node using webpack
Hello,
Iβm facing this error when I try to request the API. My project uses the following packages:
"@octokit/auth-app": "^2.4.4""@octokit/rest": "^17.1.4""typescript": "^3.8.2"
import { createAppAuth } from "@octokit/auth-app";
import { Octokit } from "@octokit/rest"
const appOctokit = new Octokit({
authStrategy: createAppAuth,
auth: {
id: APP_ID,
privateKey: PRIVATE_KEY
}
})
const { data } = await appOctokit.request("/app");
console.log(data)
"errorType": "ReferenceError",
"errorMessage": "atob is not defined",
"stack": [
"ReferenceError: atob is not defined",
" at getDERfromPEM (/var/task/webpack:/myapp/node_modules/universal-github-app-jwt/dist-web/index.js:15:1)",
" at getToken (/var/task/webpack:/myapp/node_modules/universal-github-app-jwt/dist-web/index.js:50:1)",
" at githubAppJwt (/var/task/webpack:/myapp/node_modules/universal-github-app-jwt/dist-web/index.js:71:1)",
" at getAppAuthentication (/var/task/webpack:/myapp/node_modules/@octokit/auth-app/dist-web/index.js:8:37)",
" at getInstallationAuthentication (/var/task/webpack:/myapp/node_modules/@octokit/auth-app/dist-web/index.js:110:1)",
" at dist_web_hook (/var/task/webpack:/myapp/node_modules/@octokit/auth-app/dist-web/index.js:240:20)",
...
]
I tried to install the package atob-lite cause it was a dependency in the past https://github.com/octokit/rest.js/pull/1302, but it doesnβt fix the issue.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
Did you ever find a workaround for this?
Thank you for the explanation and the links. I will take the time to read the discussion and test the different workarounds. I very appreciated your help βοΈ and your reactivity! A big THANK YOU for all your contributions to the open-source community π
@gr2m yes I think we can close it. Also in recent nodejs release (v16)
atobis expose as global https://github.com/nodejs/node/pull/37786 so it probably fixes (in a way) the issue.This issue https://github.com/webpack/webpack/issues/5756 could explain why my app is using the code under
dist-weband notdist-node.I tested this https://github.com/webpack/webpack/issues/5756#issuecomment-405468106 and it loads the correct code, but itβs not an option because it introduces potential side effects π
I tried to downgrade to β@octokit/auth-appβ: β^2.0.1β (so before introducing the browser compatibility) and I can execute the code without issue.