Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Cannot use import statement outside a module #48

Open
muhammadaqibmasood opened this issue Oct 17, 2021 · 4 comments
Open

Comments

@muhammadaqibmasood
Copy link

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

@lpetkov-sw
Copy link

lpetkov-sw commented Nov 4, 2021

Hey, I have the same problem. Did you found a solution ?
Btw, are you using nextJs ?

@caitsithlord
Copy link

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.

@d-x90
Copy link

d-x90 commented Jan 11, 2022

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.

@saadahmsiddiqui
Copy link

saadahmsiddiqui commented Jan 13, 2023

Facing this issue as well @d-x90 should we have a "module": "commonjs" in tsconfig.build.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@lpetkov-sw @muhammadaqibmasood @saadahmsiddiqui @d-x90 @caitsithlord and others