question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Buffer is not defined

See original GitHub issue

Hello,

Since I last dropped my node_modules and reinstalled them, an error appeared:

Buffer is not defined

In /modules/angular-auth-oidc-client.es5.js TokenHelperService.urlBase64Decode

The “compiled” code is the following:

    TokenHelperService.prototype.urlBase64Decode = function (str) {
        var /** @type {?} */ output = str.replace('-', '+').replace('_', '/');
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += '==';
                break;
            case 3:
                output += '=';
                break;
            default:
                throw Error('Illegal base64url string!');
        }
        return new Buffer(output, 'base64').toString('binary');
    };

But went I look at the source code, I see :

    urlBase64Decode(str: string) {
        let output = str.replace('-', '+').replace('_', '/');
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += '==';
                break;
            case 3:
                output += '=';
                break;
            default:
                throw Error('Illegal base64url string!');
        }

        return typeof window !== 'undefined' ? window.atob(output) : new Buffer(output, 'base64').toString('binary');
    }

I assume there is a release/publish problem, the package on npm not being the latest version ?

Best regards

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jperuggiacommented, Aug 2, 2018

@damienbod

Ran a test using 6.0.5, it appears to be working as of now. I also changed my package to use ^6.0.0 and all is still well. Thanks for the prompt response.

1reaction
damienbodcommented, Aug 2, 2018

@Booster2ooo @bereachad

Thanks for reporting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: Buffer is not defined - Stack Overflow
Answering my own question. Two things helped to resolve the issue: Adding plugins section with ProviderPlugin into webpack.config.js.
Read more >
Uncaught ReferenceError: Buffer is not defined #1626 - GitHub
Trying to bundle a project which includes https://solana-labs.github.io/wallet-adapter. First, I had a problem with global not being defined ...
Read more >
Buffer is not defined. Using Phantom Wallet, Solana and ...
This is happening because the default bundler that comes with create react app(webpack 5) does not polyfill Buffer .
Read more >
How to polyfill Buffer with Webpack 5 - viglucci.io
The "buffer is not defined" error is a common error that can occur when trying to use the Buffer Node.js API in an...
Read more >
ReferenceError: Buffer is not defined - Homey Community Forum
Buffer is a global variable set by homeyscript. Now it is not defined anymore. Why do you need the script? If you think...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found