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

Error: The requested module './air-datepicker.js' does not provide an export named 'default' #596

Open
yourchoice opened this issue Mar 11, 2024 · 1 comment

Comments

@yourchoice
Copy link

Error: The requested module './air-datepicker.js' does not provide an export named 'default'a

In main html I load script main.js

document.querySelector('.dpr-input')?.addEventListener("click", event => {
       const el = event.target;
	(async () => {
		const AirDatepicker =  await import('/assets/plugins/air-datepicker/index.es.js');
		//new AirDatepicker('#date_start', { });
	})();
});

Then, the file "/assets/plugins/air-datepicker/index.es.js":

import AirDatepicker from './air-datepicker.js';
export AirDatepicker; //or export default AirDatepicker;

But i get errors like: The requested module './air-datepicker.js' does not provide an export named 'default' (at index.es.js) or Uncaught (in promise) SyntaxError: Unexpected token 'export' (at index.es.js:15:1)

Please if somebody can help me how to import - export without errors.

Thank You!


@ConnectGrid
Copy link

I'm battling these module-specific errors, too. These libraries describe themselves as "dependency-free", but then are written in a way where "loading as a module" is a dependency in and of itself.

I'm currently having trouble loading a locale file dynamically, rather than using the import statement.

I hope one day this overcomplication of JavaScript can return to some level of sanity. 🤓

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

2 participants