CLI Usage & Installation
The MoroJS CLI is published as @morojs/cli. The recommended way to use it is with npx, which requires no installation. You can also install it globally if you prefer.
Prerequisites
- Node.js 18+ installed
- npm, yarn, or pnpm package manager
- Git (for version control)
- TypeScript knowledge (recommended)
Usage
Run with npx (Recommended)
1npx @morojs/cli init my-api --validation=zodThis is the standard way to use the MoroJS CLI. Anywhere you see a command in the docs, you can prefix it with npx and run it directly, with no install required.
Two ways to run init
Interactive mode
Run with no flags to get guided prompts for every option. Hit Enter on any prompt to take the recommended default.
1npx @morojs/cli init my-apiNon-interactive mode
Pass any flag (or --fast) and the CLI skips every prompt. Defaults fill in the rest:runtime=node,validation=zod,database=none.
1npx @morojs/cli init my-api --fast
2npx @morojs/cli init my-api --validation=zodGlobal Installation (Optional)
If you use the CLI frequently, install it globally so you can call it asmorojs-cli (or the short aliasmoro) directly:
1npm install -g @morojs/cli1yarn global add @morojs/cli1pnpm add -g @morojs/cliOnce installed you can run any command asmoro <command> instead ofnpx @morojs/cli <command>.
Pick a Package Manager for Your Project
init auto-detects the package manager that invoked the CLI (via npm_config_user_agent), so pnpm dlx @morojs/cli init my-apigenerates pnpm-flavoured scripts and runs pnpm installfor you. Override explicitly with --package-manager:
1npx @morojs/cli init my-api --fast --package-manager=pnpm1npx @morojs/cli init my-api --fast --package-manager=yarnpnpm users: enable the esbuild build script
pnpm v10+ blocks postinstall scripts by default, which prevents esbuild from downloading its native binary and breaks tsx/dev tooling in the generated project. Add the following to the generated package.json:
1{
2 "pnpm": {
3 "onlyBuiltDependencies": ["esbuild"]
4 }
5}Why no bun? MoroJS targets the Node.js runtime (its native engine, @morojs/engine, ships prebuilt binaries per Node ABI). Bun-as-runtime isn't officially supported yet, so we don't advertise it as an option here.
Verify It Works
1# With npx
2npx @morojs/cli --version
3
4# Or, if installed globally (any of these work)
5moro --version
6morojs-cli --version1npx @morojs/cli --helpSuccess!
If you see the version number and help output, the CLI is ready to use.
Updating the CLI
Keep your CLI up to date to access the latest features and improvements:
1npm update -g @morojs/cli1yarn global upgrade @morojs/cli1pnpm update -g @morojs/cliTroubleshooting
Common Issues
Permission errors on macOS/Linux
If you get permission errors, you may need to use sudo or configure npm to use a different directory:
1sudo npm install -g @morojs/cliCommand not found
If the command is not found after installation, check that your global npm bin directory is in your PATH:
1npm config get prefixNode.js version issues
Ensure you're using Node.js 18 or higher. Check your version with:
1node --version