Skip to content

Top-Level await in Node.js

View on Twitter

💡 Node.js 14.8 was released last week! 🚀

It brings top-level await to the masses. You can now use this feature without a feature flag.

❗️ You do need to use ES Modules. Add "type": "module" in package.json or rename .js -> .mjs.

Prior to Node.js 14.8 you had to wrap async/await in an IIFE. From Node.js 14.8 and up, you can use top-level await in ES Modules.
You might also like
How Big Tech Companies Test Code Read tip
Easily Test Your .htaccess Rewrite Rules Read tip
Quick Server for Incoming Webhooks Read tip