Installation

Get MoroJS up and running in your development environment. Follow the steps below to install and configure the framework.

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)

Installation

1Install MoroJS

Install MoroJS using your preferred package manager:

npm

typescript

1npm install @morojs/moro

yarn

typescript

1yarn add @morojs/moro

pnpm

typescript

1pnpm add @morojs/moro

2Create Your Project

Set up a new project with TypeScript configuration:

Project Setup

typescript

1# Create project directory
2mkdir my-moro-api
3cd my-moro-api
4
5# Initialize package.json
6npm init -y
7
8# Install TypeScript and development dependencies
9npm install -D typescript @types/node tsx
10
11# Create TypeScript configuration
12npx tsc --init

3Configure Scripts

Add the following scripts to your package.json:

package.json

json

1{
2  "scripts": {
3    "dev": "tsx watch src/server.ts",
4    "build": "tsc",
5    "start": "node dist/server.js"
6  }
7}

Verify Installation

Create a simple test file to verify that MoroJS is working correctly:

src/server.ts

typescript

1import { createApp } from '@morojs/moro';
2
3const app = createApp();
4
5app.get('/', () => {
6  return { 
7    message: 'Hello from MoroJS!',
8    timestamp: new Date().toISOString()
9  };
10});
11
12const port = 3000;
13app.listen(port);
14
15console.log(\`🚀 Server running at http://localhost:\${port}\`);

Run the server

typescript

1npm run dev

Success!

If everything is working correctly, you should see the server start message and be able to visithttp://localhost:3000 to see your API response.

TypeScript Configuration

For optimal TypeScript support, ensure your tsconfig.json includes these settings:

tsconfig.json

json

1{
2  "compilerOptions": {
3    "target": "ES2022",
4    "module": "NodeNext",
5    "moduleResolution": "NodeNext",
6    "esModuleInterop": true,
7    "allowSyntheticDefaultImports": true,
8    "strict": true,
9    "skipLibCheck": true,
10    "forceConsistentCasingInFileNames": true,
11    "outDir": "./dist",
12    "rootDir": "./src"
13  },
14  "include": ["src/**/*"],
15  "exclude": ["node_modules", "dist"]
16}

Troubleshooting

Common Issues

Node.js version issues

Ensure you're using Node.js 18 or higher. You can check your version 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.

Next Steps