zk-merkle-tree icon indicating copy to clipboard operation
zk-merkle-tree copied to clipboard

React JS incompatible

Open enginer opened this issue 1 year ago • 1 comments

I want to use this library with React (and Next.JS). But I got error: Module not found: Error: Can't resolve 'fs'

Steps to reproduce:

  1. Create fresh React app: yarn create react-app my-app --template typescript
  2. Add zk-merkle-tree dependency yarn add zk-merkle-tree
  3. Import zk-merkle-tree in src/App.tsx: import {generateCommitment} from "zk-merkle-tree"
  4. Call generateCommitment:
useEffect(() => {
    generateCommitment().then()
  }, [])

src/App.tsx full file example 5. Start project yarn start 6. Get errors:

ERROR in ./node_modules/ejs/lib/ejs.js 46:9-22 Module not found: Error: Can't resolve 'fs' in '<...>/node_modules/ejs/lib' And much more, here is full error message

enginer avatar Apr 14 '23 13:04 enginer