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-NetplayThe server.js file depends on a few Node.js packages:
expresssocket.iocors
Install them using npm:
npm install express socket.io corsOr using yarn:
yarn add express socket.io corsTo start the server:
node server.jsIf you want to run it in development mode with auto-restart on file changes, install nodemon:
npm install -g nodemon
nodemon server.jsBy 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.jsWindows PowerShell:
$env:PORT=4000; node server.jsFor production, use PM2 to keep the server running in the background.
Install PM2 globally:
npm install -g pm2Start the server with a name:
pm2 start server.js --name my-serverView logs:
pm2 logs my-serverRestart the server:
pm2 restart my-serverStop the server:
pm2 stop my-serverTo make PM2 auto-start after reboot:
pm2 startupFollow the instructions it gives you, then save the current process list:
pm2 saveYou now have the server running locally!
- For production, use PM2 to keep it running and restart automatically.