3

I have imported InjectedConnector from @web3-react/injected-connector in my reactJS application for connecting it to meta mask wallet but on starting the vite server I is getting this error

✘ [ERROR] No matching export in "browser-external:events" for import "EventEmitter"

../../node_modules/@web3-react/abstract-connector/dist/abstract-connector.esm.js:1:9:
  1 β”‚ import { EventEmitter } from 'events';

Any idea what is going wrong here??

This is the complete error message displayed

error when starting dev server:
Error: Build failed with 1 error:
../../node_modules/@web3-react/abstract-connector/dist/abstract-connector.esm.js:1:9: ERROR: No matching export in "browser-external:events" for import "EventEmitter"
    at failureErrorWithLog (/media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:1602:15)
    at /media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:1248:28
    at runOnEndCallbacks (/media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:1033:63)
    at buildResponseToResult (/media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:1246:7)
    at /media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:1355:14
    at /media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:665:9
    at handleIncomingPacket (/media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:762:9)
    at Socket.readFromStdout (/media/naval/Data/IIIT/Year 2/Sem 2/DASS/OfficialRepo/Source Code/oyh/node_modules/esbuild/lib/main.js:632:7)
    at Socket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:315:12)
TylerH
  • 20,799
  • 66
  • 75
  • 101
Naval
  • 31
  • 1
  • 2

1 Answers1

1

yarn add events solved my issue.

@web3-react/abstract-connector didn't add events as a dependency, and vite try to resolve dep from nodejs native maybe ?

Shauden Yu
  • 11
  • 4
  • 3
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 01 '22 at 03:49