'Regexp error in node: Cannot read properties of undefined (reading 'length')

I'm developing my first project with node and I came across this error with regexp module that I can not solve. I was thinking that it might be a problem with the routes. I begun to have this problem when I started to work with ejs so I also think the problem might be that package. Does anybody know what the problem is?

Error image

Project structure image

This is my Server code:

const express = require('express');
const cors = require ('cors');
const ejs = require('ejs')
const app = express();
const paths = require('express-path');


const fileUpload = require ('express-fileupload');


const { dbConnection } = require('../db/config');



class Server {


    constructor() {
        this.app = express();
        this.port = process.env.PORT;


        this.paths = {
            auth:           '/api/auth',
            buscar:         '/api/buscar',
            categorias:     '/api/categorias',
            productos:      '/api/productos',
            usuarios:       '/api/usuarios',
            uploads:        '/api/uploads'
        }
        //Conectar a la base de datos
        this.conectarDB();


        //Middlewares
        this.middleWares();


        //Rutas de mi aplicacion
        this.routes();
    }

    async conectarDB () {
        await dbConnection();
    }

    middleWares() {

        this.app.set('view-engine', 'ejs')



        //CORS
        this.app.use(cors());


        //Sirve para recibir datos desde la URL
        this.app.use(express.urlencoded({extended:false}));


        //Parseo y lectura del body
        this.app.use (express.json());


        //Directorio publico
        this.app.use(express.static('public'));

        //File upload- carga de archivos
        this.app.use(fileUpload({
            useTempFiles : true,
            tempFileDir : '/tmp/',
            createParentPath: true
        }));
    }

    routes() {
        this.app.use (this.paths.auth, require ('../routes/auth'));
        this.app.use (this.paths.buscar, require ('../routes/buscar'));
        this.app.use (this.paths.categorias, require ('../routes/categorias'));
        this.app.use (this.paths.productos, require ('../routes/productos'));
        this.app.use (this.paths.usuarios, require ('../routes/usuarios'));
        this.app.use (this.paths.uploads, require ('../routes/uploads'));
        
        this.app.get('/',(req,res)=>{
            res.render('index.ejs')
        })

        this.app.get('/login',(req,res)=>{
            res.render('login.ejs')
        })
 

    }

    listen(){
        this.app.listen(this.port, ()=>{
            console.log ('Servidor corriendo en puerto', this.port)
        })
    }


}



  module.exports = Server;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source