A real-time device tracking application built with Node.js, Express, Socket.IO, and Leaflet. This application allows users to track their devices' locations on a map in real-time using geolocation.
- Real-time location tracking using WebSocket.
- Interactive map interface using Leaflet.
- Custom markers for user locations.
- Dynamic tooltips displaying user IDs.
- Responsive design with smooth user experience.
- Node.js: JavaScript runtime for building the server.
- Express: Web framework for Node.js.
- Socket.IO: Enables real-time bidirectional communication between clients and server.
- Leaflet: Open-source JavaScript library for interactive maps.
- HTML/CSS: For the frontend structure and styling.
- Node.js installed on your machine.
- npm (Node package manager).
To run the application with automatic reloading, use nodemon:
- Make sure you have
nodemoninstalled globally:npm install -g nodemon Start the application: npx nodemon app.js
Make sure you have the following installed:
- Node.js (LTS version recommended)
- npm (comes with Node.js)
To verify:
node -v
npm -vgit clone https://github.com/PayalKumari10/Realtime_Tracker.git
cd Realtime_Trackergit config user.name "your_github_username"
git config user.email "[email protected]"npm installnpm install -g nodemonnpx nodemon app.jsIf nodemon isn't installed, you can just run:
node app.jsOpen your browser and go to:
http://localhost:3000
app.listen(3000, "0.0.0.0", () => {
console.log("Server is running on http://<your_ip>:3000");
});updated.features.mp4
Watch the video of updated features in 22-04-2025
"Location error: Only secure origins are allowed..."
...happens because modern browsers block geolocation on insecure origins (like http://192.168.x.x) unless it's:
- Served over HTTPS
- Or running on
localhost
If you're testing on a mobile device, access your server using:
http://localhost:3000
This only works if the server is running on the mobile device itself.
Use ngrok or localtunnel to expose your local dev server over HTTPS.
Ngrok example:
-
Run your local server:
npm start
-
In another terminal, run:
ngrok http 3000
-
Ngrok gives you an
https://URL β open that on your mobile and geolocation will work fine.
If you're testing on Chrome on Android, launch with this flag (PC only):
chrome.exe --unsafely-treat-insecure-origin-as-secure="http://192.168.0.214:3000" --user-data-dir=/test-profile --disable-web-securityPerfect choice! π LocalTunnel is lightweight and easy to set up for exposing your local server with an HTTPS URL.
Great progress! You're almost there β just a quick tweak needed.
The error you're seeing:
npm ERR! Missing script: "start"
This means your projectβs package.json file doesnβt have a "start" script defined.
Inside your project folder (Realtime_Tracker), open package.json, and look for the "scripts" section.
If thereβs no "start" script, add one like this:
"scripts": {
"start": "node app.js"
}π Replace
app.jswith whatever your main file is. Could beserver.js,index.js, etc.
Now go back to terminal and run:
Open your terminal and run:
npm install -g localtunnelMake sure your app (e.g., the map tracker) is running locally:
npm startAssuming it's on the default port 3000, or whatever port you use.
Run this in a separate terminal window:
lt --port 3000or
lt --port 3000 --subdomain akashdip2001Youβll see something like:
your url is: https://akashdip2001.loca.lt
Use that secure URL (https://akashdip2001.loca.lt) on your mobile browser β now geolocation will work because it's served over HTTPS β
β οΈ and the passward in you Hosting System'scurrent IP

