Skip to content
← Back to Community
cant run files in nodejs other than default file
Profile icon
RITIKAGARG

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

Voters
Profile icon
RahulRanjan1
Profile icon
Lathryx
Profile icon
spk2dc
Profile icon
RITIKAGARG
Comments
hotnewtop
Profile icon
vedprad1

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!

Profile icon
AtomsGV2

Hello 👋

Just Click on shell and create a
Node JS file name it whatever you want for example hello.js

And in the shell type (node hello.js
)

Profile icon
RahulRanjan1

@AtomsGV2 most easy way :)

Profile icon
ejmuentes

"auto-import" all the files at root of your repl.it
https://gist.github.com/Emuentes/ca5771fe77bcd6ea840c28395e481161