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

Uncaught SyntaxError: Cannot use import statement outside a module (at remoteEntry.js:1:1) #279

Open
ivankorobchuk123 opened this issue Nov 9, 2022 · 10 comments

Comments

@ivankorobchuk123
Copy link

I have a paths error.

Uncaught SyntaxError: Cannot use import statement outside a module (at remoteEntry.js:1:1)
Screenshot 2022-11-09 at 14 38 13

@flyfishzy
Copy link
Member

Try to add type="module" to the script. For example:

<script type="module" src="/src/main.js"></script>

@js-lowes
Copy link

Doesn't work for me. I am experiencing the same problem.

The host in my case is a Webpack and the remote is using Vite.

@ivankorobchuk123
Copy link
Author

Didn't find a solution. Changed Vite to Webpack

@adirzoari
Copy link

@js-lowes @ivankorobchuk123 did you find a solution?

@ivankorobchuk123
Copy link
Author

Sorry, no)

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Sorry, no)

@js-lowes
Copy link

@js-lowes @ivankorobchuk123 did you find a solution?

Unfortunately not, but I have tried vite plugin federation in awhile. Best of luck.

@mjangir
Copy link

mjangir commented Feb 23, 2024

This is pretty straightforward. Your remoteEntry.js from Vite is having import statements which are not allowed in browser unless the script tag has type="module" attribute. Just set the type module on the script tag and it will work fine.

Something like <script type="module" src="http://localhost:3000/assets/remoteEntry.js" />

@adirzoari
Copy link

@mjangir can you check my similar issue here? #576

@Lau08
Copy link

Lau08 commented Nov 19, 2024

Is there an update on this issue? I have also his problem
image

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

No branches or pull requests

7 participants