`global` Reference Error in Browser Environment
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- web-dev
Research direction
Start with browser.js at the linked implementation and reproduce the failure by using randombytes@2.1.0 in a browser environment built with Vite. Trace the browser-side crypto initialization and verify that the build no longer raises "global is not defined" while still accessing the browser crypto implementation.
Written by the indexing model from the issue text.
Description
When using randombytes@2.1.0 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
- Dominant language
- JavaScript
- Stars
- 102
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserify/randombytes
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
browserify/randombytes#40 ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 35/100
browserify/randombytes#37 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
browserify/randombytes#36 · 2 comments · 6 reactions ·
-
Broken on SSR Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
browserify/randombytes#33 · 2 comments · 1 reaction ·
-
remove phantomjs Open
Difficulty 1/5 Under an hour Newbie friendliness 38/100
browserify/randombytes#26 ·
All issues in browserify/randombytes
Similar issues
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AllTheMods/ATM-10-L#19 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SignalK/n2k-signalk#345 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
JuliaPluto/PlutoPlotly.jl#72 ·