modern web app build

shahab2 years ago

Hello,
I have installed modern web app and traccar backend code on local machine from github and was able to run on it by doing "npm start" on web app
But when i do "npm run build" and "server -s build" frontend show error(image attached below)
https://ibb.co/sWh0THM
later on investigation i found that when frontend load it makes a GET request to http://localhost:3000/api/server
Now when i do "npm start" this api return the server information and works fine but when i do "serve -s build" i.e run build files, it is returning me an HTML page

<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#1a237e"/><meta name="description" content="GPS tracking system"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><link rel="stylesheet" href="/styles.css"><title>Tracker</title><script defer="defer" src="/static/js/main.c1b28d2f.js"></script><link href="/static/css/main.becf9d2c.css" rel="stylesheet"></head><body><noscript>Enable JavaScript to use <a href="https://www.traccar.org//">GPS Tracking System</a>.</noscript><div id="root" class="root"></div></body></html>

This causing error in parsing the respose and showing the error. why web app is working fine on npm start but not serve -s build while in both case traccar backend code is running?

For my particular use case
I have Updated modern web app interface and also develop separate custom backend along with traccar backend. Now i have to host web app on a separate ec2 and since it is react i want start server with react build folder

Anton Tananaev2 years ago

Where did you get the server -s build from?

shahab2 years ago

by doing "npm run build"

shahab2 years ago

Here is the screenshot of it
https://ibb.co/zsq0xvy

Anton Tananaev2 years ago

OK. That's the standard output of the tools we're using. You can't actually deploy it like that. You have to deploy it in Traccar.

Rona year ago

Hello,
I followed the directions after downloading. I am on Ubuntu Linux 22.04. After installing using npm install, I then run npm start, but I get the following error:

npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rongonzalez/.npm/_logs/2023-09-01T03_53_01_566Z-debug-0.log

Please advise...

Anton Tananaeva year ago

Are you sure you're running it from the correct folder?

Rona year ago

Apologies. I misread the directions. It's running for me now.