Ask coding questions

← Back to all posts
cant run files in nodejs other than default file
RITIKAGARG (0)

how to run my nodejs file other than the default file?

Commentshotnewtop
vedprad1 (477)

Unfortunately, on repl.it you cannot run any file except the original file. If you want to run another file on node.js, you can do this:

index.js:

const other = require('./other.js');
other();

other.js:

module.exports = () => {
    //your code here
};

If this is answer is correct, please check the checkmark on the left side of this message. Thanks and Good Luck!