Getting Started
Manual Installation
Set up MoroJS by hand: prerequisites, ESM, package install, and TypeScript configuration. For most users, the CLI quick start is faster.
Most users should use the CLI quick start
npx @morojs/cli init my-api handles ESM, TypeScript, validation, and a working dev server for you. This page is for users who want to set up MoroJS manually.
What You'll Learn
- How to verify your system requirements
- Install MoroJS using your preferred package manager
- Set up your project for ESM (ES Modules)
- Configure TypeScript for optimal development
Check Prerequisites
Before installing MoroJS, ensure you have the following:
- Node.js 18.0.0 or higher
- npm, yarn, or pnpm package manager
- TypeScript knowledge (recommended)
Tip: Check your Node.js version with node --version
Understand ESM Requirements
ESM-Only Framework
MoroJS is built exclusively for modern JavaScript and requires ESM (ES Modules). Your project must use "type": "module" in package.json.
If you're migrating from CommonJS, convert your imports/exports to ESM syntax.
Install MoroJS
Install MoroJS using your preferred package manager:
1npm install @morojs/moro1yarn add @morojs/moro1pnpm add @morojs/moroWhat this does: Installs MoroJS and its dependencies. The package includes everything you need to get started.
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. Add the following to your package.json:
1{
2 "pnpm": {
3 "onlyBuiltDependencies": ["esbuild"]
4 }
5}Configure Your Project
Ensure your package.json includes:
1{
2 "type": "module",
3 "scripts": {
4 "dev": "tsx watch src/server.ts",
5 "build": "tsc",
6 "start": "node dist/server.js"
7 }
8}And your tsconfig.json has ESM support:
1{
2 "compilerOptions": {
3 "target": "ES2022",
4 "module": "NodeNext",
5 "moduleResolution": "NodeNext",
6 "esModuleInterop": true,
7 "strict": true
8 }
9}Result: Your project is now configured for ESM and ready for MoroJS development.
Troubleshooting
Common Issues
Node.js version issues
Ensure you're using Node.js 18 or higher. Check with node --version.
TypeScript compilation errors
Make sure your tsconfig.json has "moduleResolution": "NodeNext"and "esModuleInterop": true.
Import/export issues
Use ES modules syntax: import { createApp } from '@morojs/moro'instead of CommonJS require.