{"record":{"id":"d2fc1a300f4f93c1","repo":"facebook/flow","slug":"usage-flow-dot-js-wasm-packager-js-raw-js-outp","errorCode":null,"errorMessage":"Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>","messagePattern":"Usage: flow_dot_js_wasm_packager\\.js <raw-js> <output-js> <post-js>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/flow_dot_js_wasm_packager.js","lineNumber":21,"sourceCode":" *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n */\n\n'use strict';\n\nconst fs = require('fs');\nconst path = require('path');\nconst zlib = require('zlib');\n\nconst input = process.argv[2];\nconst output = process.argv[3];\nconst postJs = process.argv[4];\n\nif (input == null || output == null || postJs == null) {\n  throw new Error(\n    'Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>',\n  );\n}\n\nfunction getWasmSidecarPath(rawJsPath) {\n  return path.join(\n    path.dirname(rawJsPath),\n    path.basename(rawJsPath, path.extname(rawJsPath)) + '.wasm',\n  );\n}\n\nfunction runtimeShim() {\n  return `var window = typeof window !== 'undefined'\n  ? window\n  : typeof globalThis !== 'undefined'\n    ? globalThis\n    : {};\nvar process = undefined;","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/facebook/flow/blob/d1341dac899a79c027762f6b423d896045287620/src/flow_dot_js_wasm_packager.js#L3-L39","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Invoke with all three paths: node flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>.","If driven by a build script, echo the assembled command to spot the empty/unset path variable.","Quote paths containing spaces and use absolute or correct relative paths from the invocation directory.","Check for accidentally consuming a flag as input — this CLI takes no options, only three positional paths."],"exampleFix":"# before\nnode flow_dot_js_wasm_packager.js out/flow_dot_js.js\n\n# after\nnode flow_dot_js_wasm_packager.js out/flow_dot_js.js out/flow_dot_js.packaged.js resources/post.js","handlingStrategy":"validation","validationCode":"const [rawJs, outputJs, postJs] = process.argv.slice(2);\nif (rawJs == null || outputJs == null || postJs == null) {\n  console.error('Usage: flow_dot_js_wasm_packager.js <raw-js> <output-js> <post-js>');\n  process.exit(1);\n}\nfor (const p of [rawJs, outputJs, postJs]) {\n  if (!require('fs').existsSync(p)) {\n    console.error(`missing input file: ${p}`);\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`node flow_dot_js_wasm_packager.js ${rawJs} ${outJs} ${postJs}`);\n} catch (err) {\n  if (err.stderr?.toString().includes('Usage: flow_dot_js_wasm_packager.js')) {\n    // a build variable was empty; log the assembled command and fail the build loudly\n    throw new Error(`packager invoked with missing args: raw=${rawJs} out=${outJs} post=${postJs}`);\n  }\n  throw err;\n}","preventionTips":["Echo the fully assembled packager command from build scripts so empty variables are visible.","Treat any output from this script starting with 'Usage:' as a build configuration bug, not a source bug.","Keep the three-path contract in the build macro; this CLI accepts no flags."],"tags":["cli","build","packager","usage","arguments"],"backgroundTag":"missing-cli-arguments","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}