title: Regexp error in node: Cannot read properties of undefined (reading 'length')
body: <p>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?</p>
  <p><a href="https://i.stack.imgur.com/v7GUi.png" rel="nofollow noreferrer">Error image</a></p>
  <p><a href="https://i.stack.imgur.com/v0NJG.png" rel="nofollow noreferrer">Project structure image</a></p>
  <p>This is my Server code:</p>
  <pre><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)=&gt;{
              res.render('index.ejs')
          })
  
          this.app.get('/login',(req,res)=&gt;{
              res.render('login.ejs')
          })
   
  
      }
  
      listen(){
          this.app.listen(this.port, ()=&gt;{
              console.log ('Servidor corriendo en puerto', this.port)
          })
      }
  
  
  }
  
  
  
    module.exports = Server;
  </code></pre>