Run function in script from command line (Node JS)

前端 未结 11 477
情书的邮戳
情书的邮戳 2020-12-07 07:25

I\'m writing a web app in Node. If I\'ve got some JS file db.js with a function init in it how could I call that function from the command line?

11条回答
  •  执笔经年
    2020-12-07 08:08

    I do a IIFE, something like that:

    (() => init())();
    

    this code will be executed immediately and invoke the init function.

提交回复
热议问题