NodeJS MODULE_TYPELESS_PACKAGE_JSON error after nodejs update

NodeJS MODULE_TYPELESS_PACKAGE_JSON error after nodejs update

por Aleksi Postari -
Número de respuestas: 0

Hi!


I have updated the built-in NodeJS version that came with Coderunner to latest NodeJS version 22.7.0. I did this update manually in the Jobe server. This allowed us to use all the latest features, like string.replaceAll().


Now, the issue I am seeing is below. I have attached the answer, test case, and output below, where the output below throws this ugly MODULE_TYPELESS_PACKAGE_JSON error:


Question Type:

NodeJS


Answer:

    const simulatedServer = async (simulatedError) => { //tänne ei tarvitse koskea

        // Simuloi palvelinviivettä

        const delay = 500; //viive 3s

        await new Promise(resolve => setTimeout(resolve, delay));

        return simulatedError ? {response:"error", delay:delay} : {response:"ok", delay:delay,message:"Hey there!"};

    }


    const theFunction = async (simulatedError) => {

        // Kirjoita koodisi tähän

        console.log("odota");

        const result = await simulatedServer(simulatedError);


        if(result.response === "error"){

            return "Server Error";

        }else{

            return result.message ?? "Default message";

        }

    };


Test Case 1:

let result = await theFunction();

console.log(result)

result = await theFunction(true);

console.log(result)


Output:

odota
Hey there!
odota
Server Error

***Run error***
(node:281667) [MODULE_TYPELESS_PACKAGE_JSON] Warning: file://__tester__.js parsed as an ES module because module syntax was detected; to avoid the performance penalty of syntax detection, add "type": "module" to /package.json
(Use `nodejs --trace-warnings ...` to show where the warning was created)

Now, I have been figuring that I might need to just add the --input-type=module to the nodejs command that gets run, or add package.json file to the folder where the code is executed where I add "type": "module", but I am not sure which is the location, or how to edit that nodejs executable in Jobe to include that extra parameter. Any ideas? :)