browserify / browserify/randombytes

`global` Reference Error in Browser Environment

Abierto
#38 0 comentarios 2 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
102
Forks
47
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

When using `randombytes@2.1.0` in a browser environment with Vite as the build tool, the following error occurs:

```bash
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:

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

As the source code mentioned below `crypto` is defined correctly

https://github.com/browserify/randombytes/blob/b4eb4126fccc503e375853ca7b3e96aaa34af9e6/browser.js#L15-L16

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
web-dev
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.