facebook/flow · error · Error

Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <po

Error message

Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>

What it means

flow_dot_js_wasm_packager.js is a build-time CLI that requires exactly three positional arguments — the Emscripten raw JS output, the destination JS path, and the post-JS file — and throws this usage error during argument validation when any of process.argv[2..4] is missing. It is pure argv checking before any file I/O happens, so seeing it means the script was invoked with the wrong number of arguments, not that anything is wrong with the build inputs. The usage string doubles as the complete argument contract.

Source

Thrown at src/flow_dot_js_wasm_packager.js:21

 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 */

'use strict';

const fs = require('fs');
const path = require('path');
const zlib = require('zlib');

const input = process.argv[2];
const output = process.argv[3];
const postJs = process.argv[4];

if (input == null || output == null || postJs == null) {
  throw new Error(
    'Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>',
  );
}

function getWasmSidecarPath(rawJsPath) {
  return path.join(
    path.dirname(rawJsPath),
    path.basename(rawJsPath, path.extname(rawJsPath)) + '.wasm',
  );
}

function runtimeShim() {
  return `var window = typeof window !== 'undefined'
  ? window
  : typeof globalThis !== 'undefined'
    ? globalThis
    : {};
var process = undefined;

View on GitHub (pinned to d1341dac89)

Solutions

  1. Invoke with all three paths: node flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>.
  2. If driven by a build script, echo the assembled command to spot the empty/unset path variable.
  3. Quote paths containing spaces and use absolute or correct relative paths from the invocation directory.
  4. Check for accidentally consuming a flag as input — this CLI takes no options, only three positional paths.

Example fix

# before
node flow_dot_js_wasm_packager.js out/flow_dot_js.js

# after
node flow_dot_js_wasm_packager.js out/flow_dot_js.js out/flow_dot_js.packaged.js resources/post.js
Defensive patterns

Strategy: validation

Validate before calling

const [rawJs, outputJs, postJs] = process.argv.slice(2);
if (rawJs == null || outputJs == null || postJs == null) {
  console.error('Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>');
  process.exit(1);
}
for (const p of [rawJs, outputJs, postJs]) {
  if (!require('fs').existsSync(p)) {
    console.error(`missing input file: ${p}`);
    process.exit(1);
  }
}

Try / catch

try {
  execSync(`node flow_dot_js_wasm_packager.js ${rawJs} ${outJs} ${postJs}`);
} catch (err) {
  if (err.stderr?.toString().includes('Usage: flow_dot_js_wasm_packager.js')) {
    // a build variable was empty; log the assembled command and fail the build loudly
    throw new Error(`packager invoked with missing args: raw=${rawJs} out=${outJs} post=${postJs}`);
  }
  throw err;
}

Prevention

When it happens

Trigger: Running `node flow_dot_js_wasm_packager.js out/flow_dot_js.js` (missing output-js or post-js); a build script/Buck macro invoking the packager with an unset variable that expands to nothing; passing flags (e.g. --help or an option) in a position where a path is expected.

Common situations: Hand-running a build step that is normally driven by Buck with all three paths; refactoring build scripts where one path variable becomes empty; new contributors probing the script's interface with no arguments.

Related errors


AI-assisted analysis of facebook/flow@d1341dac89 (2026-08-17). Data as JSON: /api/errors/d2fc1a300f4f93c1. Report an issue: GitHub.