I
I
ince2019-12-01 17:34:28
JavaScript
ince, 2019-12-01 17:34:28

How to use the same function for both export and run directly through the console with parameters?

How to use the same function, placed in a separate file (module), both for export and for launching directly through the console with parameters?
Let there be a file called mod.js like

const func = (arg) => console.log( arg + 1 )

module.exports = func

I want to call func from the console like this
node mod func 5
output to the console
6

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question