How to split a node script written in JavaScript into multiple files:

// hello.js
function hello() {
    console.log("hello")
}

module.exports = {hello};
// test.js
const { hello } = require("./hello");
hello();

Run test.js

node test.js

hello.js contains the functions to export.

test.js imports the functions from hello.js

note: the require path needs to path to the file that contains the export.

note: require is a node specific construct - do not expect this to work in the browser.