Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
Uncaught SyntaxError: Unexpected token '<' error

I tried to run my app on localhost using nodejs but i keep on getting this error : Uncaught SyntaxError: Unexpected token '<' .

This is my app.js code:

const http = require('http')
const fs = require('fs')
const port = 3000

const server = http.createServer(function(req,res){
    res.writeHead(200,{'Content-Type':'text/html'})
    fs.readFile('templates/index.html',null,function(error,data){
        if(error){
            res.writeHead(404)
            res.write('Error: File Not Found')
        } else {
            res.write(data)
        }
        res.end()
    })
})

server.listen(port,function(error){
    if(error){
    console.log('something went wrong', error)
    }else{
    console.log('server is listening on port ' + port)
    }
})

I tried looking into other threads that discussed this but I'm pretty new to this and I have no clue what they are talking about just following YouTube tutorials at the moment.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!