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

global Reference Error in Browser Environment #38

Open
0xharshrastogi opened this issue Nov 13, 2024 · 0 comments
Open

global Reference Error in Browser Environment #38

0xharshrastogi opened this issue Nov 13, 2024 · 0 comments

Comments

@0xharshrastogi
Copy link

When using [email protected] in a browser environment with Vite as the build tool, the following error occurs:

Uncaught ReferenceError: global is not defined

This error stems from the browser.js implementation attempting to access the global object which is not available in browser DOM environments:

var Buffer = require('safe-buffer').Buffer
var crypto = global.crypto || global.msCrypto

As the source code mentioned below crypto is defined correctly

randombytes/browser.js

Lines 15 to 16 in b4eb412

const _global = typeof globalThis !== 'undefined' ? globalThis : global
const crypto = _global.crypto || _global.msCrypto

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

1 participant