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

后端 未结 30 3377
梦如初夏
梦如初夏 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

    Optimist (node-optimist)

    Check out optimist library, it is much better than parsing command line options by hand.

    Update

    Optimist is deprecated. Try yargs which is an active fork of optimist.

提交回复
热议问题