Node.js Hybrid eXecutor (a `uvx` inspired tool)
npm install nhxnhx - Node.js Hybrid eXecutor (a uvx inspired tool)

A hybrid of node ./script.js and npx package - run scripts or packages with automatic dependency handling.
``bash`
npm install -g nhx
- Self-contained scripts - Scripts declare their own dependencies and just work
- No project setup - No package.json, no npm install, no node_modules
- Share scripts easily - Send a single file that anyone can run
- Fast - Dependencies are cached globally, subsequent runs are instant
- Works offline - Once cached, no network needed
``
--with
--engine
--run-postinstall Allow postinstall scripts (disabled by default)
-h, --help Show help
All other flags pass through to node.
`bashRun an npm package
nhx cowsay hello
Self-contained scripts
Scripts can declare their own dependencies inline:
`javascript
// hello.mjs
/*/ //
{ dependencies: { chalk: "^5.0.0" } }
/*/ // import chalk from 'chalk';
console.log(chalk.green('Hello!'));
``bash
nhx ./hello.mjs
`Dependencies are installed automatically on first run and cached for future runs.
$3
`javascript
/*/ //
{ engines: { node: ">=18 <21" } }
/*/ // console.log(process.version);
`If your current node satisfies the range, it's used directly. Otherwise nhx downloads an appropriate version.
$3
Use tsx as a declared dependency and as a loader:
`typescript
#!/usr/bin/env -S nhx --with=tsx --import tsx
import { something } from './other.ts';
`You can also do that with inline dependencies:
`typescript
#!/usr/bin/env -S nhx --import tsx
/*/ //
{ devDependencies: { tsx: "^4" } }
/*/ //
``MIT