unionlabs/union · error · Error

Usage: node site/scripts/import-contentful-export.mjs <previ

Error message

Usage: node site/scripts/import-contentful-export.mjs <preview-export> <delivery-export>

What it means

Usage guard in site/scripts/import-contentful-export.mjs: the script expects exactly two positional CLI arguments — the directory of the Contentful preview export and the directory of the delivery export — and throws this usage line as an Error when either is missing.

Source

Thrown at site/scripts/import-contentful-export.mjs:13

// @ts-nocheck
import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises"
import { basename, extname, join, relative } from "node:path"
import { fileURLToPath } from "node:url"

const LOCALE = "en-US"
const SITE_DIRECTORY = fileURLToPath(new URL("..", import.meta.url))
const REPOSITORY_ROOT = fileURLToPath(new URL("../..", import.meta.url))

const [previewDirectory, deliveryDirectory] = process.argv.slice(2)

if (!previewDirectory || !deliveryDirectory) {
  throw new Error(
    "Usage: node site/scripts/import-contentful-export.mjs <preview-export> <delivery-export>",
  )
}

const archiveDirectory = join(
  SITE_DIRECTORY,
  "content",
  "archive",
  "contentful",
)
const assetDirectory = join(SITE_DIRECTORY, "public", "content", "assets")
const dataDirectory = join(SITE_DIRECTORY, "src", "content-data")
const blogDirectory = join(SITE_DIRECTORY, "src", "content", "blog")
const legalDirectory = join(SITE_DIRECTORY, "src", "content", "legal")

for (
  const directory of [
    archiveDirectory,

View on GitHub (pinned to 031785bb6d)

Solutions

  1. Invoke with both export directories: node site/scripts/import-contentful-export.mjs <preview-export> <delivery-export>
  2. If wrapped in an npm script, pass args through with "--": npm run import:contentful -- ./tmp/preview ./tmp/delivery
  3. Confirm both directories exist and contain the Contentful export JSON before running

Example fix

# before
node site/scripts/import-contentful-export.mjs

# after
node site/scripts/import-contentful-export.mjs ./tmp/contentful-preview ./tmp/contentful-delivery
Defensive patterns

Strategy: validation

Validate before calling

const [previewDirectory, deliveryDirectory] = process.argv.slice(2)
if (!previewDirectory || !deliveryDirectory) {
  console.error("Usage: node site/scripts/import-contentful-export.mjs <preview-export> <delivery-export>")
  process.exit(1)
}
// plus: assert both directories exist via stat() before doing work

Try / catch

try {
  execFileSync("node", [script, previewDir, deliveryDir], { stdio: "inherit" })
} catch (error) {
  // non-zero exit with the usage line means arguments were not forwarded; check wrapper quoting
}

Prevention

When it happens

Trigger: Running node site/scripts/import-contentful-export.mjs with zero or one argument; quoting mistakes that collapse the two paths into one; running from a script runner that drops positional args.

Common situations: New contributor running the docs-import script for the first time; CI job or npm script not forwarding arguments; shell aliases that swallow the second path.

Related errors


AI-assisted analysis of unionlabs/union@031785bb6d (2026-08-16). Data as JSON: /api/errors/d32f6838d0b4ae16. Report an issue: GitHub.