Search code examples
node.jsnodemondotenv

Mysterious parameter -r in Nodemon


I've been searching on how to reload env on the development environment while using Nodemon.

The command that spread all over on the internet is nodemon -r dotenv/config bin/www.js, this is actually working, but look at the command, what is the -r thing? I'm out of curiosity.

I've been searching on the official documentation with no luck. https://github.com/remy/nodemon/wiki

Anyone care to explain, thank you.


Solution

  • I finally found an answer.

    Quoted from Nodemon docs:

    nodemon wraps your application, so you can pass all the arguments you would normally pass to your app https://github.com/remy/nodemon#usage

    So basically any arguments that unknown to Nodemon will redirect to Node.js app, so -r is passed to the Node.js, which means "Require module".

    See: https://nodejs.org/dist/latest-v12.x/docs/api/cli.html#cli_r_require_module