我在reactJS应用程序中从@web3 react/injected连接器导入了InjectedConnector,用于将其连接到元掩码钱包,但在启动vite服务器时,我收到了此错误
✘ [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';
知道这里出了什么问题吗??
这是显示的完整错误消息
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)
yarn add events
解决了我的问题。
@web3-react/abstract-connector
没有添加events
作为依赖项,是否尝试从nodejs native解析dep?