Skip to content

EmulatorJS/EmulatorJS-Netplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Running Your Own Netplay Server

This guide explains how to run the Netplay server designed specifically for Emulatorjs.org


1. Prerequisites

Before you begin, ensure you have the following installed on your system:


2. Clone the Repository

git clone https://github.com/EmulatorJS/EmulatorJS-Netplay
cd EmulatorJS-Netplay

3. Install Dependencies

The server.js file depends on a few Node.js packages:

  • express
  • socket.io
  • cors

Install them using npm:

npm install express socket.io cors

Or using yarn:

yarn add express socket.io cors

4. Run the Server

To start the server:

node server.js

If you want to run it in development mode with auto-restart on file changes, install nodemon:

npm install -g nodemon
nodemon server.js

5. Access the Server

By default, the server runs on:

http://localhost:3000

If you want to change the port, set the PORT environment variable.

Linux / macOS (bash / zsh):

PORT=4000 node server.js

Windows PowerShell:

$env:PORT=4000; node server.js

6. (Optional) Run in Background with PM2

For production, use PM2 to keep the server running in the background.

Install PM2 globally:

npm install -g pm2

Start the server with a name:

pm2 start server.js --name my-server

View logs:

pm2 logs my-server

Restart the server:

pm2 restart my-server

Stop the server:

pm2 stop my-server

7. (Optional) Keep Server Running After Reboot

To make PM2 auto-start after reboot:

pm2 startup

Follow the instructions it gives you, then save the current process list:

pm2 save

✅ Done

You now have the server running locally!

  • For production, use PM2 to keep it running and restart automatically.