How do I pass command line arguments to a Node.js program?

后端 未结 30 2657
梦如初夏
梦如初夏 2020-11-22 04:03

I have a web server written in Node.js and I would like to launch with a specific folder. I\'m not sure how to access arguments in JavaScript. I\'m running node like this:

30条回答
  •  情歌与酒
    2020-11-22 04:28

    The best way to pass command line arguments to a Node.js program is by using a Command Line Interface (CLI)

    There is a nifty npm module called nodejs-cli that you can use.

    If you want to create one with no dependencies I've got one on my Github if you wanna check it out, it's actually quite simple and easy to use, click here.

提交回复
热议问题