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

ERROR ReferenceError: btoa is not defined #1

Open
robertsmieja opened this issue Feb 18, 2020 · 3 comments
Open

ERROR ReferenceError: btoa is not defined #1

robertsmieja opened this issue Feb 18, 2020 · 3 comments

Comments

@robertsmieja
Copy link

robertsmieja commented Feb 18, 2020

I'm using this plugin with mdx.js - https://mdxjs.com/ and next.js - https://nextjs.org/

The project is located at - https://github.com/robertsmieja/nextjs-md-sandbox

Steps the reproduce:

  1. Uncomment the remark-code-screenshot plugin in next.config.js
  2. npm run dev

This is the code that seems be causing the issue:

var getCodeScreenshot = function () {
    var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(src) {
        var codeType, srcArg, res;
        return _regenerator2.default.wrap(function _callee$(_context) {
            while (1) {
                switch (_context.prev = _context.next) {
                    case 0:
                        codeType = "javascript", srcArg = btoa(src);
                        _context.next = 3;
                        return fetch("https://84wz7ux5rc.execute-api.us-east-1.amazonaws.com/default/screenshot-as-a-service-dev-screenshot-function?type=code&code=" + srcArg + "&codeType=" + codeType);

                    case 3:
                        res = _context.sent;
                        return _context.abrupt("return", res.text());

                    case 5:
                    case "end":
                        return _context.stop();
                }
            }
        }, _callee, this);
    }));

    return function getCodeScreenshot(_x) {
        return _ref.apply(this, arguments);
    };
}();

OS: Windows 10 64-bit
Node.js: v12.16.0
npm: 6.13.4

@TicTak21
Copy link

TicTak21 commented Oct 7, 2020

+1

@bluprince13
Copy link

I had the same issue - also with next.js and mdx. I think it's because btoa is only available on the browser and not with node. I'm not sure how to solve it though.

@bluprince13
Copy link

See nodejs/node#3462

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