sodium-friends / sodium-native

Low level bindings for libsodium
MIT License
300 stars 64 forks source link

unable to run sodium-native with expo #152

Closed cbidon42 closed 5 months ago

cbidon42 commented 2 years ago

Hello

I am trying to use sodium-native within expo application.

_import some lib ..._ 
import { sodium }  from 'sodium-native';

export const Profile = (props: Props) => {
   useEffect(() => {
       const myRand = sodium.randombytes_random();
       console.log(myRand);
   }, [])
  //some code after
;

So very basic. Now I have the following error message.


`undefined Unable to resolve module fs from /some_absolute_path/node_modules/node-gyp-build/index.js: fs could not be found within the project or in these directories:
  node_modules
  ../../node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
> 1 | var fs = require('fs')
    |                   ^
  2 | var path = require('path')
  3 | var os = require('os')
`

```I have installed node-gyp-build with yarn `yarn add node-gyp-build` (I see it is a depency for sodium-native).
but still I have the issue.

I have tried to install 'fs' with yarn  `yarn add fs` or react-native-fs  but it does not work either.
``While trying to resolve module `fs` from file `/some_absolute_path/node_modules/node-gyp-build/index.js`, the package `/Users/olivier/Dev/expecto/node_modules/fs/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/some_absolute_path/node_modules/fs/index.js`. Indeed, none of these files exist:`

Any clue ?

Many thanks.

mafintosh commented 5 months ago

try latest