简体   繁体   English

Nodemon等效于npm run dev

[英]Nodemon aequivalent to npm run dev

I've just started using the whole javascript and node.js environment. 我刚刚开始使用整个javascript和node.js环境。 To start an existing project I run three commands npm install , npm run all and finally npm run dev to start the application in my browser. 要启动现有项目,我运行三个命令npm installnpm run all ,最后npm run dev以在浏览器中启动应用程序。

Now, whenever I update the code I stop the current running dev via Ctrl+C , press arrow up key to get npm run dev in my terminal again and hit Enter . 现在,无论何时更新代码,我都会通过Ctrl+C停止当前正在运行的开发人员,按向上箭头键再次在终端中获取npm run dev并按Enter I believe there is a better way of doing this repetitive task, like Nodemon . 我相信有一种更好的方法可以执行此重复性任务,例如Nodemon

But, what is the aequivalent command for that, so that the updates I make in the code automatically become visible in the browser? 但是,与此等效的命令是什么,以便我在代码中进行的更新在浏览器中自动可见?

I have three files which do not work with nodeman: package.json , Gruntfile.js , app/index.js . 我有三个不能与nodeman一起使用的文件: package.jsonGruntfile.jsapp/index.js Moreover, I tried nodemon --exec npm run dev which permanently does sth, but does not start my application. 此外,我尝试了nodemon --exec npm run dev ,它可以永久执行nodemon --exec npm run dev操作,但不会启动我的应用程序。

Do you have any suggestions? 你有什么建议吗?

Yes, I would look at the --exec flag on nodemon . 是的,我将查看nodemon上的--exec标志。 You could do something like: 您可以执行以下操作:

nodemon --exec npm run dev

This will run npm run dev every time a source file changes. 每当源文件更改时,它将运行npm run dev Read the nodemon NPM page to get a better idea of how to use it. 阅读nodemon NPM页面 ,以更好地了解如何使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM