N4JS CLI
raw JSON → 0.37.9 verified Fri May 01 auth: no javascript
Command-line interface for the N4JS language, including the compiler and build tools. Current version is 0.37.9, with monthly releases following the N4JS project cadence. It provides a CLI to compile N4JS code to JavaScript, and supports custom runtimes. Differentiators include deep integration with the Eclipse ecosystem and a static type system targeting JavaScript. Note: this is a niche tool; for mainstream use, consider TypeScript or other transpilers.
Common errors
error Error: Could not find or load main class org.eclipse.n4js.n4jsc.Main ↓
cause n4jsc.jar is missing or corrupted; environment variable N4JSC_JAR not set correctly.
fix
Ensure n4jsc.jar is present in the package or set N4JSC_JAR to a valid path/URL.
error n4js-cli: command not found ↓
cause n4js-cli not installed globally or not in PATH.
fix
Install globally:
npm install -g n4js-cli or use npx: npx n4js-cli Warnings
gotcha n4js-cli requires Java Runtime Environment (JRE) 8+ to execute the underlying n4jsc.jar. ↓
fix Install JRE 8 or later and ensure java is in PATH.
gotcha The package is a CLI tool; it cannot be imported as a JavaScript module. ↓
fix Use it via command line: `npx n4js-cli` or global install.
deprecated Older versions (pre-0.25) used a different command structure; ensure documentation matches installed version. ↓
fix Upgrade to latest version and refer to current CLI help: `n4js-cli --help`
Install
npm install n4js-cli yarn add n4js-cli pnpm add n4js-cli Imports
- n4jsc.jar wrong
import { n4js } from 'n4js-cli';correctn4js-cli invokes the Java CLI; no import in JS/TS code. Use as a command-line tool via `npx n4js-cli`. - n4js-cli (global command) wrong
const n4js = require('n4js-cli');correctnpm install -g n4js-cli then run `n4js-cli compile`
Quickstart
// n4js-cli is a CLI tool, not a library.
// Install globally:
// npm install -g n4js-cli
// Then compile N4JS files:
// n4js-cli compile src/ -d out/
// Alternative using npx:
// npx n4js-cli compile src/ -d out/