Gun: Sea can not be required in a node environment

Created on 24 Nov 2018  路  3Comments  路  Source: amark/gun

First of all, I think the lack of browserify/node/webpack instructions is a big missed opportunity. I'm pretty sure most web developers use these tools, so making that on-ramp smooth is a big obstacle to adoption.

Trying to require SEA throws this error:

> let SEA = require('gun/sea')
@trust/webcrypto and text-encoding are not included by default, you must add it to your package.json!
node-webcrypto-ossl is temporarily needed for ECDSA signature verification, and optionally needed for ECDH, please install if needed (currently necessary so add them to your package.json for now).
ReferenceError: TRUST_WEBCRYPTO_OR_TEXT_ENCODING_NOT_INSTALLED is not defined
    at /Users/danfinlay/Documents/Development/irv-voter/node_modules/gun/sea.js:186:7

I'm unclear how to do what's requested here. I added these dependencies to my own package.json but no change in behavior.

I tried starting some browserify docs but they don't work yet, I need to get this sorted out first.

Most helpful comment

Its simple ... if you depend on it, it needs to be in the dependencies !
If its a dependency of sea then maybe it could be in that project's dependencies.

A (poor) alternative would be to add sections in the README with explicit instructions for environments where you don't do what developers expect you to have done. (e.g. explicit instructions for browserify, webpack and nodejs)

All 3 comments

@danfinlay yes. It is important to me that everything should work with different environments (especially popular tools like browserify/webpack/etc.), I'm glad you opened this up and updated docs - they are lacking cause I have 0 experience with those tools and depend upon community reports/fixes.

I'd love to hear your thoughts on this. Browser WebCrypto is great, but NodeJS support sucks badly... complicating the dependencies (but these dependencies are not needed in Browser).

  • (A) if we include the crypto libraries by default as a dependency, it causes npm install gun to take 10X longer to install and fails on a lot of machines.
  • (B) so we reverted to not including them by default, but then we have to throw these errors prompting you to use devDependencies, but improves the first use experience for 90% of 1st time GUN users who aren't using the crypto pieces yet.

What is the right balance?

Its simple ... if you depend on it, it needs to be in the dependencies !
If its a dependency of sea then maybe it could be in that project's dependencies.

A (poor) alternative would be to add sections in the README with explicit instructions for environments where you don't do what developers expect you to have done. (e.g. explicit instructions for browserify, webpack and nodejs)

Another solution that meets both requirements would be putting sea into its own module, so gun installation would not install, sea, but sea would install all of its dependencies.

That also solves the compatibility issue for those users.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ronsku picture Ronsku  路  4Comments

amark picture amark  路  3Comments

Xsmael picture Xsmael  路  3Comments

Sarajin picture Sarajin  路  6Comments

biocrypto730 picture biocrypto730  路  5Comments