I created a page for routes that I attempted to run on Visual Studio Code's live server but was unsuccessful due to issues with the require functions. It is essential for me to utilize this feature for navigating through different profile pages. (I have had success running everything via terminal using node routes.js and linking all my js and css files within the static directory)
const path = require('path');
const express = require('express');
const app = express();
app.use('/static', express.static('public'))
app.get('/user=:username', function (req, res) {
res.sendFile(path.join(__dirname + '/profile.html'));
});
I tried searching for "How to use require function on local server" and "How to use require function on website" but couldn't find any relevant information after scrolling through several pages for each query. Can anyone provide assistance? Thank you, I hope I explained everything clearly.