Nub
An all-in-one TypeScript-first toolkit for Node.js that enhances performance and developer experience without replacing your existing Node runtime.
Nub is an all-in-one Rust-based toolkit designed to modernize the Node.js developer experience without replacing the runtime. It augments the Node.js installation you already have, enabling seamless execution of TypeScript files, faster package management, optimized script running, and integrated Node version management. By leveraging Node's own public extension surfaces, such as module.registerHooks(), preloads, and environment configuration, Nub provides a highly compatible and zero-lock-in environment that allows existing Node.js projects to benefit from advanced developer tooling without requiring migration or changes to the underlying runtime.
Functionally, Nub acts as a drop-in replacement for standard commands like node, npm run, and npx. It orchestrates the developer environment by handling transpilation, dependency installation, and CLI tool execution in a single native binary. The tool uses a Rust-powered addon to transpile code in memory, ensuring that even complex TypeScript and modern ECMAScript features work directly on your existing node installation.
Some of the key features are:
- TypeScript-first Runtime: Execute .ts, .tsx, and .jsx files on stock Node with full tsconfig.json support.
- Faster Script Runner: Run package.json scripts with negligible overhead compared to pnpm run or npm run.
- Efficient Package Management: A pnpm-compatible installer that respects existing lockfiles from npm, pnpm, or bun.
- Built-in Node Manager: Automatically provisions and manages Node versions based on project pins like .node-version or .nvmrc.
- Instant CLI Execution: Use nubx to resolve and run binaries from node_modules/.bin in milliseconds, significantly faster than npx.
- Auto-restart Watcher: A dependency-aware watch mode that restarts processes based on the full dependency graph, including .env and tsconfig files.
- Modern API Polyfills: Automatically provides polyfills for Web APIs like Temporal, URLPattern, and Worker.
- YAML/TOML Support: Enables native importing of configuration files like .yaml, .toml, .jsonc, and .json5 directly in code.
Nub operates by wrapping standard Node.js execution with a thin Rust-based orchestration layer. When you run a command, Nub detects the project configuration, sets up the necessary runtime flags, and injects a pre-loading hook. This hook handles the transpilation, polyfilling, and environment injection before passing control to the stock Node.js binary. Because it does not modify the Node.js source or ship a custom runtime, all Node.js features, native addons, and compatibility guarantees remain fully intact. The toolchain effectively integrates into existing workflows, allowing developers to keep their current package managers and CI setups while gaining immediate performance and convenience improvements.
Some common use cases include:
- TypeScript Development: Running TypeScript entry points directly without requiring a separate compilation step or ts-node setup.
- Monorepo Management: Using nub run with workspace-aware filters to execute scripts across complex monorepos with high performance.
- Quick Tool Invocation: Using nubx to run project-local CLIs like prisma, eslint, or vitest without the startup latency of npx.
- Node Version Consistency: Ensuring that every developer and CI environment uses the exact Node version defined in a project configuration file automatically.
- Simplified Configuration: Loading .env files and environment variables automatically without needing additional packages like dotenv.
Comments
0Markdown is supported.