0

i am setting up the route for my application, the file i want to target is signup.html located in code-FE folder while the file i am working on server.js is located in BE folder as shown below enter image description here

and every time I "res. send" to file signup.html it shows error path is not defined. this is my code, can someone show me how to fix it

const express = require('express')
const app = express()
const port = 3000

app.set('view engine', 'html');
app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, '../code-FE', 'signup.html'));
})
app.listen(port, () => {
   console.log(`Example app listening on port http://localhost:${port}`)
})
aynber
  • 22,380
  • 8
  • 50
  • 63

1 Answers1

0

You forgot to import the path module

Add this const path = require('path'); for node v < 18 or const path = require('node:path'); for node v 18

Yuriy Vorobyov
  • 755
  • 4
  • 8