CLI
Node.js --input-type
Selects module interpretation for eval or stdin input. It is not a replacement for package type or file extension when loading files. Tested on Node.js 22.16.0. Example output (one line per entry): ["string"].
Formal Syntax & Structure
nodejs syntaxnodejs
node --input-type=module --eval "source"Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| module | string | Input module type. |
Return Value
Process output
Result depends on the invoked program.
Working Example
Example Snippetnodejs
import { execFileSync } from 'node:child_process';import { writeFileSync, mkdtempSync, rmSync } from 'node:fs';import { join } from 'node:path';import { tmpdir } from 'node:os';const dir = mkdtempSync(join(tmpdir(), 'bytemind-'));try { const result = execFileSync(process.execPath, ["--input-type=module", "-e", "console.log(typeof import.meta.url)"], { cwd: dir, env: { PATH: process.env.PATH, HOME: dir, ...{} }, encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'pipe'] }); console.log(result.trim());}finally { rmSync(dir, { recursive: true, force: true });}