Nodemon中的神秘参数-r

Mysterious parameter -r in Nodemon

我一直在寻找如何在使用 Nodemon 时在开发环境中重新加载 env。

网上流传的命令是nodemon -r dotenv/config bin/www.js,其实是可以的,但是看命令,-r是什么东西?我是出于好奇。

我一直在搜索官方文档,但没有成功。 https://github.com/remy/nodemon/wiki

哪位大神解释一下,谢谢

-r 不是有效的参数选项 看看

https://github.com/remy/nodemon/blob/master/lib/cli/parse.js

对于所有支持的选项

终于找到答案了

引自 Nodemon 文档:

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

所以基本上任何 unknownNodemon 的参数都会重定向到 Node.js 应用程序,所以 -r 被传递给 Node.js,意思是"Require module".

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