Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
running node.js using systemd but systemd couldn't find html

Using raspberry pi4, express for server, get data through socket.io, and send the data to client side(html) and log on rest API.

The problem is that systemd couldn't find html file. When I run $ sudo systemctl start FileToServer.service HTML shows me this error message.

Error: ENOENT: no such file or directory, stat '/index.html' 
  1. $ node server.js is working. and i can see what i want and there isn't any error messages.
  2. sudo systemctl start FileToServer.service can also run the server.js
  3. I checked sudo systemctl status FileToServer.service, and confirmed active is active(running).
  4. I also run using $ sudo su and it didn't work

What can i do ?

[Unit]
Description=usb lte

[Service]
Type=simple
ExecStart=/usr/bin/node /home/pi/Desktop/rpi4_clientside/server.js
Restart=on-failure
#User=pi
#User=root
#Group=root

[Install]
WantedBy=multi-user.target

This is the code snippet i'm struggling. server.js

    import express from "express";
    const app = express();
    import { SerialPort } from "serialport";
    import { ReadlineParser } from "@serialport/parser-readline";

    import { createServer } from "http"; 
    import { Server } from "socket.io";
    const httpServer = createServer(app);
    const io = new Server(httpServer, {});

    import axios from "axios";
    import path from 'path';
    const __dirname = path.resolve();
    const PORTnum = 3000;
    const publicIp = "222.33.222.33"
    const localIp = "172.3.1.2"
    const serverSidePort = "5500"
    let api_url = `http://${publicIp}:${serverSidePort}/gps`;

    httpServer.listen(PORTnum, () => {
      console.log(`it's alive on http://localhost:${PORTnum}`);
    })

    app.use(express.json())

    app.get("/", (req, res) => {
      // console.log(res);
      res.sendFile(__dirname + "/index.html");
    });

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda