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)

No install needed

bash

1npx @morojs/cli init my-api --validation=zod

This 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 — 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.

No flags

bash

1npx @morojs/cli init my-api

Non-interactive mode

Pass any flag (or --fast) and the CLI skips every prompt. Defaults fill in the rest:runtime=node,validation=zod,database=none.

Any flag, or --fast

bash

1npx @morojs/cli init my-api --fast
2npx @morojs/cli init my-api --validation=zod

Global Installation (Optional)

If you use the CLI frequently, install it globally so you can call it asmorojs-cli (or the short aliasmoro) directly:

npm

bash

1npm install -g @morojs/cli

yarn

bash

1yarn global add @morojs/cli

pnpm

bash

1pnpm add -g @morojs/cli

Once 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:

Generate a pnpm project

bash

1npx @morojs/cli init my-api --fast --package-manager=pnpm

Generate a yarn project

bash

1npx @morojs/cli init my-api --fast --package-manager=yarn

Why no bun? MoroJS targets the Node.js runtime (it depends on uWebSockets.js' native N-API bindings). Bun-as-runtime isn't officially supported yet, so we don't advertise it as an option here.

Verify It Works

Check version

bash

1# With npx
2npx @morojs/cli --version
3
4# Or, if installed globally (any of these work)
5moro --version
6morojs-cli --version

View help

bash

1npx @morojs/cli --help

Success!

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:

npm

bash

1npm update -g @morojs/cli

yarn

bash

1yarn global upgrade @morojs/cli

pnpm

bash

1pnpm update -g @morojs/cli

Troubleshooting

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:

Fix permissions

bash

1sudo npm install -g @morojs/cli
Command not found

If the command is not found after installation, check that your global npm bin directory is in your PATH:

Check npm path

bash

1npm config get prefix
Node.js version issues

Ensure you're using Node.js 18 or higher. Check your version with:

Check Node version

bash

1node --version

Next Steps