holepunchto / hypercore

Hypercore is a secure, distributed append-only log.
https://docs.holepunch.to
MIT License
2.57k stars 183 forks source link

Browser: Use of requiring hypercore with browserify, not working #237

Closed moskalyk closed 3 years ago

moskalyk commented 4 years ago

Getting the following error on hypercore import in a react app that is transpiled using browserify.

Ex. Use:

const hypercore = require( 'hypercore' )

Setup

OS: Mac (Catalina) / Windows Browsers: Opera, Chrome, Beaker Experienced the same error on all:

TypeError: Cannot read property 'variables' of undefined
    at Object.<anonymous> (bundle.js:148994)
    at Object.1051._process (bundle.js:149144)
    at o (bundle.js:1)
    at bundle.js:1
    at Object.<anonymous> (bundle.js:148974)
    at Object.1050.node-gyp-build (bundle.js:148978)
    at o (bundle.js:1)
    at bundle.js:1
    at Object.<anonymous> (bundle.js:53240)
    at Object.633../cipher-state (bundle.js:53744)

Digging further, error on line:

var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : process.config.variables.arm_version) || ''

Had importing hypercore working before in browser. Even tried downgrading to v7.12, no luck.

Thoughts?

mjp0 commented 4 years ago

@moskalyk did you get this working?

emilbayes commented 4 years ago

It won't work in the browser atm due to missing crypto primitives I'm pretty sure

mafintosh commented 3 years ago

works now

moskalyk commented 3 years ago

Thank you - seem to still be getting this error:

/node_modules/sodium-javascript/memory.js
Module not found: Can't resolve 'worker_threads'
mafintosh commented 3 years ago

@moskalyk what env? browserify etc etc?