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: require() cannot be used on an ESM graph with top-level await. #247

Open
timint opened this issue Nov 14, 2024 · 4 comments
Open

Comments

@timint
Copy link

timint commented Nov 14, 2024

I think there is a dependancy problem when importing this module. To see where the top-level await comes from, use --experimental-print-required-tla.

import svgtofont from 'svgtofont';

Error: require() cannot be used on an ESM graph with top-level await. Use import() instead.

svgtofont 6.0.1
Node 23.1.0

@chronolai
Copy link

It's work for me

CleanShot 2024-12-16 at 15 55 45

@timint
Copy link
Author

timint commented Dec 17, 2024

Is this something you provided for a fix? That doesn't look to be ESM use. Is your file gulpfile.mjs?

@SeanHayes
Copy link

SeanHayes commented Feb 21, 2025

Same:

$ node  --experimental-print-required-tla node_modules/.bin/gulp iconfont
Error: unexpected top-level await at file:///<redacted>/node_modules/svgtofont/node_modules/ttf2woff2/dist/index.js:9
        ttf2woff2 = (await import('bindings')).default('addon.node').convert;
                     ^

I'm using a gulpfile.mjs.

@timint
Copy link
Author

timint commented Feb 21, 2025

Try this fix here for the ttf2woff2 library:
nfroidure/ttf2woff2#87

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

3 participants