nu-require

nu-require is a small TypeScript library CLIs call at startup to require Nushell as the host shell. It either continues under Nu, relaunches the same binary and argv via nu -c, or errors with an install path when nu is missing. PowerShell is not an alternate supported host.

Nushell-tailored CLIs call validate() near process start:

import { validate } from "@openshellorg/nu-require";

await validate({ offerInstall: true });

Behavior:

  1. Already under Nushell → continue normally.

  2. Not under Nushell, but nu is on PATH → print that the tool is relaunching inside Nushell, then re-exec the same binary/argv via nu -c.

  3. nu missing → clear error, link to https://www.nushell.sh/, optionally offer a one-shot install when offerInstall: true.

In this module