This guide explains how to run the Netplay server designed specifically for Emulatorjs.org
Before you begin, ensure you have the following installed on your system:
-
Node.js (v16 or later recommended)
👉 Download Node.js -
npm (comes with Node.js) or yarn package manager
-
Git
👉 Download Git
git clone https://github.com/EmulatorJS/EmulatorJS-Netplay
cd EmulatorJS-Netplay
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
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
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
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
To make PM2 auto-start after reboot:
pm2 startup
Follow the instructions it gives you, then save the current process list:
pm2 save
You now have the server running locally!
- For production, use PM2 to keep it running and restart automatically.