NodeJS Workspace Type
The NodeJS workspace type provides a runtime environment for JavaScript/TypeScript applications including Next.js, Nuxt, Express, and headless frontend projects.
Web Server Configuration
Section titled “Web Server Configuration”Unlike PHP workspaces where the web server invokes PHP-FPM directly, the NodeJS web server acts as a reverse proxy — it forwards incoming HTTP traffic to the port where your Node application is listening. Your application is responsible for handling requests and sending responses; the web server simply routes traffic to it.
Shell Environment
Section titled “Shell Environment”When you SSH into a NodeJS workspace, the following tools and paths are pre-configured:
Node.js & npm
Section titled “Node.js & npm”# Check versionsnode -vnpm -v
# Run a scriptnode app.js
# Install dependenciesnpm install
# Run package scriptsnpm run devnpm run buildnpm startYarn, pnpm, and Bun
Section titled “Yarn, pnpm, and Bun”Alternative package managers are supported. If your project uses one, the workspace will auto-detect it from your lock file and install it if needed:
yarn installpnpm installbun installRun packages without installing them globally:
npx create-next-app@latestnpx prisma migrate devPre-Installed CLI Tools
Section titled “Pre-Installed CLI Tools”Beyond Node.js and package managers, the following tools are available out of the box:
| Tool | Command | Purpose |
|---|---|---|
| PM2 | pm2 | Process manager (see below) |
| Yarn | yarn | Package manager |
| AWS CLI | aws | AWS service management |
| Kiro CLI | kiro | AI-assisted development |
| MySQL client | mysql | Database access |
| PostgreSQL client | psql | Database access |
| MongoDB Shell | mongosh | MongoDB access |
| Git | git | Version control |
| jq | jq | JSON processing |
| rsync | rsync | File synchronization |
Framework-Specific Usage
Section titled “Framework-Specific Usage”Next.js
Section titled “Next.js”cd /home/web/html
# Development servernpm run dev
# Production buildnpm run buildnpm start
# Lintnpm run lintcd /home/web/html
# Developmentnpm run dev
# Build and previewnpm run buildnpm run preview
# Generate static sitenpm run generateExpress / Custom Servers
Section titled “Express / Custom Servers”cd /home/web/html
# Start servernode server.js
# Or with npm scriptnpm start
# Development with auto-reload (if configured)npm run devProcess Management with PM2
Section titled “Process Management with PM2”NodeJS workspaces use PM2 as the process manager. PM2 runs your application, restarts it on crash, and persists process state across workspace restarts.
How It Works
Section titled “How It Works”When the workspace environment starts, the following sequence runs automatically:
-
Check for a start command — If no start command is configured in the Ordin admin, the startup script exits and no app is launched. You can still SSH in and run things manually.
-
Check for the project directory — The app is expected to live in
/home/web/project. If this directory doesn’t exist, startup is skipped. -
Resurrect saved processes — If PM2 has a saved process list from a previous session (
~/.pm2/dump.pm2), it restores those processes. If the saved start command matches the current configuration, the app is considered already running and no further action is taken. -
Detect and install the package manager — If
package.jsonexists, the workspace determines which package manager to use (see below) and installs it globally if it’s not already available. -
Install dependencies — Runs
<package-manager> installin the project directory. -
Start the application — PM2 launches the app using the configured start command, registers it under the name
app, and saves the process list for future restarts.
If you change the start command in the Ordin admin, PM2 detects the mismatch on next startup, removes the old process, and re-launches with the new command.
The start command and PM2 enablement are configured through the Ordin Workspace Manager admin — you don’t set these yourself.
Package Manager Detection
Section titled “Package Manager Detection”During startup, the workspace automatically detects which package manager to use for install, in this order of priority:
- Explicit configuration — if set in the Ordin admin
- Lock file detection —
yarn.lock→ yarn,pnpm-lock.yaml→ pnpm,bun.lockb/bun.lock→ bun - Default — npm
If the detected package manager isn’t already installed, it will be installed globally via npm before running install.
Common PM2 Commands
Section titled “Common PM2 Commands”# View running processespm2 list
# View application logspm2 logspm2 logs app
# Restart your applicationpm2 restart app
# Stop your applicationpm2 stop app
# Delete a process from PM2pm2 delete app
# Monitor CPU/memory in real timepm2 monit
# Save current process list (persists across restarts)pm2 saveEnvironment Variables
Section titled “Environment Variables”Ordin automatically injects environment variables into the workspace to pass configuration values to your application. These are set by the platform based on your workspace and project settings — you don’t manage them directly.
Commonly used variables:
| Variable | Example | Description |
|---|---|---|
WORKSPACE_DOMAIN_1 | myapp.project.ordinlabs.io | Primary workspace URL |
WORKSPACE_DB_HOST | db | Database hostname |
WORKSPACE_DB_NAME | workspace_abc | Database name |
WORKSPACE_DB_USER | root | Database user |
WORKSPACE_DB_PASSWORD | (set automatically) | Database password |
WORKSPACE_NAME | myapp | Workspace subdomain |
PORT | 3000 | Port your app should listen on |
Your application code can reference these to connect to services without hardcoding values. See Workspace Config Templates for the full list.
Common Tasks
Section titled “Common Tasks”Testing HTTP Output
Section titled “Testing HTTP Output”curl -H "Host: $WORKSPACE_DOMAIN_1" http://localhostDatabase Access
Section titled “Database Access”# MySQLmysql -h db -u root -p $WORKSPACE_DB_NAME
# Or from your app via environment variablesDATABASE_URL="mysql://$WORKSPACE_DB_USER:$WORKSPACE_DB_PASSWORD@$WORKSPACE_DB_HOST/$WORKSPACE_DB_NAME"Checking Logs
Section titled “Checking Logs”# PM2 application logspm2 logs
# Web server proxy logstail -f /var/log/nginx/error.logFile Structure
Section titled “File Structure”/home/web/├── html/ # Web root (application code)│ ├── package.json│ ├── node_modules/│ └── ...├── .bashrc # Personal shell config└── .workspacerc # Workspace-specific config
/shared/ # Shared across project workspaces├── .profile # Project-wide shell profile├── .bashrc # Project-wide bash config├── bin/ # Shared scripts (in $PATH)└── startup.d/ # Scripts run on environment start