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
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, 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.

No flags
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
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
1npm install -g @morojs/cli
yarn
1yarn global add @morojs/cli
pnpm
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
1npx @morojs/cli init my-api --fast --package-manager=pnpm
Generate a yarn project
1npx @morojs/cli init my-api --fast --package-manager=yarn

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

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

Check version
1# With npx
2npx @morojs/cli --version
3
4# Or, if installed globally (any of these work)
5moro --version
6morojs-cli --version
View help
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
1npm update -g @morojs/cli
yarn
1yarn global upgrade @morojs/cli
pnpm
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
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
1npm config get prefix
Node.js version issues

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

Check Node version
1node --version

Next Steps