{"record":{"id":"cab998d240100a07","repo":"nodejs/node","slug":"cannot-find-out-dir-did-you-run-build","errorCode":null,"errorMessage":"Cannot find out dir, did you run build?","messagePattern":"Cannot find out dir, did you run build\\?","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"tools/build_addons.py","lineNumber":104,"sourceCode":"      continue\n    test_dirs.append(full_path)\n\n  with ThreadPoolExecutor() as executor:\n    codes = executor.map(node_gyp_rebuild, test_dirs)\n    return 0 if all(code == 0 for code in codes) else 1\n\ndef get_default_out_dir(args):\n  default_out_dir = os.path.join('out', args.config)\n  if not args.is_win:\n    # POSIX platforms only have one out dir.\n    return default_out_dir\n  # On Windows depending on the args of GYP and configure script, the out dir\n  # could be 'out/Release', 'out/Debug' or just 'Release' or 'Debug'.\n  if os.path.exists(default_out_dir):\n    return default_out_dir\n  if os.path.exists(args.config):\n    return args.config\n  raise RuntimeError('Cannot find out dir, did you run build?')\n\ndef main():\n  if sys.platform == 'cygwin':\n    raise RuntimeError('This script does not support running with cygwin python.')\n\n  parser = argparse.ArgumentParser(\n      description='Install headers and rebuild child directories')\n  parser.add_argument('target', help='target directory to build addons')\n  parser.add_argument('--headers-dir',\n                      help='path to node headers directory, if not specified '\n                           'new headers will be generated for building',\n                      default=None)\n  parser.add_argument('--out-dir', help='path to the output directory',\n                      default=None)\n  parser.add_argument('--loglevel', help='loglevel of node-gyp',\n                      default='silent')\n  parser.add_argument('--skip-tests', help='skip building tests',\n                      default='')","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/build_addons.py#L86-L122","documentation":"Raised by get_default_out_dir in Node's tools/build_addons.py on Windows: it tries 'out/<config>' then the bare '<config>' directory and, if neither exists, concludes the project was never built and aborts. On POSIX the single out/<config> path is returned without this check.","triggerScenarios":"Running build_addons.py on Windows (args.is_win true) where neither out/Release (or out/Debug) nor a top-level Release/Debug directory is present — i.e. node-gyp configure/build was never run for that config.","commonSituations":"Building native addons on Windows before building Node itself; mis-matched --config value (e.g. --config Release when only Debug was built); running from the wrong working directory so the out/ tree isn't found.","solutions":["Build Node first with the matching config so out/<config> exists, e.g. vcbuild.bat release or the equivalent configure + build step.","Pass the correct --config matching an existing output dir, or use --out-dir to point at it explicitly.","Run build_addons.py from the Node source root where the out/ tree lives."],"exampleFix":"# before\npython tools/build_addons.py ./myaddon --config Release\n# after (build node first, then point at the real out dir)\nvcbuild.bat release\npython tools/build_addons.py ./myaddon --config Release --out-dir out/Release","handlingStrategy":"validation","validationCode":"import os\ndef resolve_out_dir(config: str, out_dir: str = None) -> str:\n    if out_dir:\n        if not os.path.isdir(out_dir): raise FileNotFoundError(f'--out-dir not found: {out_dir}')\n        return out_dir\n    for candidate in (os.path.join('out', config), config):\n        if os.path.isdir(candidate):\n            return candidate\n    raise FileNotFoundError(f'No output dir for config {config!r}; build Node first.')","typeGuard":"null","tryCatchPattern":"try:\n    out = get_default_out_dir(args)\nexcept RuntimeError:\n    print('Build Node for this config first, or pass --out-dir.'); raise","preventionTips":["Build Node with the matching config before building addons.","Use --out-dir to point at an existing build explicitly on Windows.","Run build_addons.py from the Node source root."],"tags":["node","addons","windows","build-output","configuration"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}