nodent-compiler
raw JSON → 3.2.13 verified Fri May 01 auth: no javascript maintenance
nodent-compiler is a core compiler for transforming ES7 async/await syntax into ES5-compatible code. Version 3.2.13 is the latest stable release, with a slow release cadence. It supports multiple compilation modes including ES7, Promises, generators, and engine, with options for sourcemaps, lazy thenables, and ES6 target. Compared to Babel or TypeScript, nodent specifically targets Node.js environments and offers fine-grained control over async transformation without additional syntax extensions. It requires nodent-runtime for certain modes and Promises availability.
Common errors
error Cannot find module 'nodent-runtime' ↓
cause Compiled code requires nodent-runtime at runtime when using es7 or generators mode without noRuntime.
fix
Install nodent-runtime: npm install nodent-runtime, or set options promises:true and noRuntime:true to avoid the dependency.
error TypeError: NodentCompiler is not a constructor ↓
cause NodentCompiler was imported incorrectly (e.g., using default import in ESM) or called without new.
fix
Use const NodentCompiler = require('nodent-compiler'); then new NodentCompiler();
error Cannot read property 'code' of undefined ↓
cause compiler.compile() was called with wrong number of arguments or missing required options.
fix
Ensure call signature is compiler.compile(sourceCode, filename, options) where filename can be null but must be present.
error Unexpected token: keyword «await» ↓
cause Source code contains await outside async function or without proper options enabled.
fix
Ensure the function is declared async and that the compiler options include promises: true or appropriate mode.
Warnings
breaking Version 3.0.0 changed the compile method signature: second argument is now filename, not options. ↓
fix Update calls from compiler.compile(sourceCode, options) to compiler.compile(sourceCode, filename, options).
gotcha nodent-compiler does not have TypeScript type definitions; using with TypeScript requires custom .d.ts or any. ↓
fix Declare module or use require: const NodentCompiler = require('nodent-compiler');
gotcha When using es7 or generators mode, nodent-runtime must be installed and accessible at runtime. ↓
fix Run npm install nodent-runtime or set promises:true and noRuntime:true to avoid runtime dependency.
deprecated The 'es7' mode is deprecated in favor of 'promises' mode. ↓
fix Use promises: true instead of es7: true.
gotcha The compiler does not support const/let or arrow functions unless es6target: true is set. ↓
fix Enable es6target: true to allow ES6 syntax in source code.
Install
npm install nodent-compiler yarn add nodent-compiler pnpm add nodent-compiler Imports
- NodentCompiler wrong
import NodentCompiler from 'nodent-compiler';correctconst NodentCompiler = require('nodent-compiler'); const compiler = new NodentCompiler(); - NodentCompiler constructor wrong
NodentCompiler()correctnew NodentCompiler() - compiler.compile wrong
compiler.compile({sourceCode, filename, options})correctcompiler.compile(sourceCode, filename, options)
Quickstart
const NodentCompiler = require('nodent-compiler');
const compiler = new NodentCompiler();
const sourceCode = `async function fetchData() { return await Promise.resolve(42); }`;
const result = compiler.compile(sourceCode, 'test.js', { promises: true, noRuntime: true, sourcemap: false });
console.log(result.code);