[英]Notify app.js if it run from "npm run dev" or "npm start"
Is that possible to notify app.js file or any other file that I am using a specific script from package.json?是否可以通知 app.js 文件或我正在使用来自 package.json 的特定脚本的任何其他文件? my relevant scripts我的相关脚本
"dev":"nodemon app.js",
"start":"node app.js"
In my case i have cron functions that run on background, its a problem when I using nodemon and some of those function invoked I kill them before them ended.在我的例子中,我有在后台运行的 cron 函数,当我使用 nodemon 时出现问题,其中一些 function 调用我在它们结束之前杀死它们。
on other way, its more convenient to use nodemon on development, so i want to know if there is a way to notify my app.js if it run from "npm start" or "npm run dev"另一方面,在开发中使用 nodemon 更方便,所以我想知道如果它从“npm start”或“npm run dev”运行,是否有办法通知我的 app.js
What about using arguments?使用 arguments 怎么样?
"dev":"nodemon app.js dev",
"start":"node app.js production"
process.argv
holds a list of all arguments, including dev
and production
now which can then be used to distinguish the two cases. process.argv
包含所有 arguments 的列表,现在包括dev
和production
,然后可以用来区分这两种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.