es-async
raw JSON → 1.1.0 verified Fri May 01 auth: no javascript
ES2017 async/await transpiler backed by nodent-compiler. Stable v1.1.0, low release cadence. Compiles async functions into ES2016-compatible Promise chains. Differentiates from Babel by targeting strict native Promise behavior with minimal runtime overhead. CLI and programmatic APIs available.
Common errors
error TypeError: compileAsync is not a function ↓
cause Importing incorrectly using named import instead of default
fix
Use: const compileAsync = require('es-async');
error Cannot find module 'es-async/from-file' ↓
cause Running in environment where subpath exports are not supported
fix
Use direct path: require('es-async/from-file') (Node >=12) or copy file.
Warnings
gotcha compiled output uses native Promises; ensure runtime supports Promise ↓
fix Polyfill Promise if targeting older environments.
deprecated require('es-async/from-file') returns a function, but future versions may change export shape ↓
fix Check documentation for new submodule exports.
gotcha Code compiled by es-async may be larger than alternatives like Babel due to verbose Promise wrapping ↓
fix Consider minification after compilation.
Install
npm install es-async yarn add es-async pnpm add es-async Imports
- compileAsync wrong
const compileAsync = require('es-async')correctimport compileAsync from 'es-async' - compileAsyncFromFile wrong
const compileAsyncFromFile = require('es-async/from-file')correctimport compileAsyncFromFile from 'es-async/from-file' - from-file
import compileFromFile from 'es-async/from-file'
Quickstart
const compileAsync = require('es-async');
const es2017Code = `async function foo() { return await bar; }`;
const es2016Code = compileAsync(es2017Code);
console.log(es2016Code);