How can I use multiple Files in a NodeJS Repl?
somecodingguy (0)

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

You are viewing a single comment. View All
Coder100 (18925)

using object destructoring, if your file was

module.exports = { a: "1", b: 2 };

then you can import like

const { a, b } = require("...");