sol-wallet-adapter
sol-wallet-adapter copied to clipboard
SyntaxError: Cannot use import statement outside a module
C:\Users\Bloctech\Documents\solana\solr-token-sale\js\node_modules@project-serum\sol-wallet-adapter\dist\cjs\index.js:79 import EventEmitter from 'eventemitter3'; ^^^^^^
SyntaxError: Cannot use import statement outside a module
Hey, I have the same problem. Did you found a solution ? Btw, are you using nextJs ?
Ran into the same issue while using next.js
I was able to resolve it by replacing the lines with common js syntax
import EventEmitter from 'eventemitter3';
with
const EventEmitter = require('eventemitter3');
Doing the same with all imports in the module and replacing
export default
with module.exports =
was able to resolve the issue for me.
If you are using next.js make sure, you don't use anything in global context from @project-serum\sol-wallet-adapter e.g.:
new Wallet("https://www.sollet.io", cluster);
shouldn't be called on top level of your file because next will try to call it on the server-side.
Facing this issue as well @d-x90 should we have a "module": "commonjs"
in tsconfig.build.json