How can I use multiple Files in a NodeJS Repl?
I am a creating a chat app and I want to be able to use multiple server-side files. I have created a demo Repl as linked. I tried using const file = require('indexOne.js');
but it thinks I want to install. How can I do this?
Thank you
EpicGamer007
put ./
in the string for the require.
but how would I access a function from the other file?
use module.exports to export a variable, function, or object.
@somecodingguyusing object destructoring, if your file was
then you can import like
@somecodingguysame thing
@somecodingguyfunctions are variables???
no, here is the correct example:
you only do destructuring for objects.
@somecodingguy