- JavaScript 97.4%
- HTML 2.5%
|
|
||
|---|---|---|
| .github/workflows | ||
| archived | ||
| CHANGELOG.md | ||
| LICENSE | ||
| README.md | ||
| server.js | ||
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:
-
Node.js (v16 or later recommended)
👉 Download Node.js -
npm (comes with Node.js) or yarn package manager
-
Git
👉 Download Git
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:
expresssocket.iocors
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.