nodemon
Hello friends, don’t tell me you aren’t tired of opening command prompt every second to type node app.js whenever you make changes to your code.
朋友们,您好,不要告诉我您对代码进行更改时不需每秒打开命令提示符来键入nodeapp.js 。
It’s annoying at times, right?
有时候很烦,对不对?
Today, let’s see a third party app that helps us avoid visiting the console all the time after making changes on our code...
今天,让我们来看一个第三方应用程序,它可以帮助我们避免在对代码进行更改之后一直访问控制台...
Like said before, Node modules are like libraries which help us perform specific tasks. Node JS is always considered powerful because it has a very large ecosystem of third-party modules.
如前所述,Node模块就像是可以帮助我们执行特定任务的库。 节点JS一直被认为是功能强大的,因为它具有非常大的第三方模块生态系统。
The NODEMON module is a third-party module built by some experts to help us avoid the stress of visiting that ugly command line all the time just to type 2 words.
NODEMON模块是由一些专家构建的第三方模块,可帮助我们避免仅输入2个单词就一直访问丑陋命令行的压力。
Take Note! You should have Node js in your PC.
做记录! 您的PC中应该有Node js。
With Node js already up and running, let’s get started.
Node Node js已经启动并运行,让我们开始吧。
Now, let’s get started.
现在,让我们开始吧。
First of all, install the nodemon module by typing npm install nodemon on the command line,
首先,通过在命令行上键入npm install nodemon来安装nodemon 模块 ,
![nodemon module download and use step 1](https://i-blog.csdnimg.cn/blog_migrate/e9ddfe14b247a4555de55affe8e7094c.png)
Wait for a while as it downloads.
NB: Internet required!
等待下载。
注意:需要互联网!
Here is how it works...
下面是它的工作原理...
After creating your wonderful node app, no need using node app.js again, rather use nodemon app or nodemon app.js
创建出色的节点应用程序后,无需再次使用node app.js,而应使用nodemon app或nodemon app.js
This module automatically detects new changes or updates in your source code file and then initiates the file again immediately after it’s saved.
该模块会自动检测源代码文件中的新更改或更新,然后在保存文件后立即再次启动该文件。
Let’s see,
让我们来看看,
Open a text editor and type the following code and save it with the file name app.js:
打开一个文本编辑器,输入以下代码,并将其保存为文件名app.js :
const os = require('os');
console.log("Platform: " + os.platform());
console.log("Architecture: " + os.arch());
console.log (" Free memory: " + os.freemem() );
//console.log("Host name: " + os.hostname());
The file should be saved in your default Node.js directory.
该文件应保存在默认的Node.js目录中。
One line of code has been left as comment. It’ll serve as an update to our code later.
剩下一行代码作为注释。 稍后将用作我们代码的更新。
![nodemon module download and use step 2](https://i-blog.csdnimg.cn/blog_migrate/c3cae92f9cc06cc75a191b0ee9b27516.png)
Our app just started and the output displayed on our console.
我们的应用程序刚刚启动,输出显示在控制台上。
Let’s update the code and see how it automatically outputs the result of the last line of code.
让我们更新代码,看看它如何自动输出最后一行代码的结果。
![nodemon module download and use step 3](https://i-blog.csdnimg.cn/blog_migrate/7038f3c77a071aabf974a21b595f795b.png)
![nodemon module download and use step 4](https://i-blog.csdnimg.cn/blog_migrate/2788a4ab4bd84b9bfc1f7420fade65ed.png)
Thanks for coding with me. Your comments are most welcome.
感谢您与我一起编码。 非常欢迎您发表评论。
翻译自: https://www.includehelp.com/node-js/nodemon-third-party-module.aspx
nodemon