Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
NodeJS Static function is not a function

I made a NodeJS application which usere a static Method to do some calculation Function. When i try to acces the Method i got the isNotAFunction Error.

Here a static class which causes the error while accessing it:

exports.module = class PlaceEvaluator
{
    static testMethod()
    {
        console.log("Test");
    }
}

Here is the Code of the file which throws the Exception while reading:

PositionFinder = require("./positionFinder.js");
PlaceObj = require("./placeObj.js");
PlaceEvaluator = require("./placeEvaluator.js");
fetch = require("cross-fetch");
const express = require("express");
const http = require("http").createServer(express);
const io = require("socket.io")(http, {
    cors:{
        origin: "*"
    }
});



const application = express();

application.use(express.static("public"));

PlaceEvaluator.testMethod();

io.on("connection", socket => {
    socket.on("placeQuery", async ({topic, lat, long}) => {
       
        PlaceEvaluator.testMethod();  //Here is the Exception function call 
       
        //console.log("Response sent!");
    })
})

async function findPlaceObject(type, lat, long)
{
    let placeObj = await PositionFinder.FetchPosition(type, lat, long);
    return placeObj;
}

function convertToPlaceObjArr(inputObj)
{
    var outputArr = [];

    let name;
    let lat;
    let long;
    

    for(var i = 0; i < inputObj.results.length; i++)
    {
        name = inputObj.results[i].name;
        lat = inputObj.results[i].geometry.location.lat;
        long = inputObj.results[i].geometry.location.lng; 
        outputArr.push(new PlaceObj(name, lat, long));
        console.log(inputObj.results[i].name);
    }

    return outputArr;
}


http.listen(4000, function(){
    console.log("Running on Port 4000");
    // PositionFinder.FetchPosition("Pizza", "51.896359", "6.982303");
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use module.exports to export a default rather than exports.module.

By using exports.module you are exporting your class with the key of module so in that case you would have to do:

PlaceEvaluator.module.testMethod();
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda