nodemon

nodemon帮助我们,当我们修改文件时,node程序自动从新执行。

安装

1
> npm install -g nodemon

原始文件

app.js:

1 2 3 4 5 6 7 8 9 10
console.log('Start app.'); const _  = require('lodash'); 判断是否为字符串 console.log(_.isString(true)); console.log(_.isString("abc")); //筛选重复数组 var filteredArray = _.uniq(['Jonson',1,'Jonson',1,2,3,4]); console.log(filteredArray);

打开控制台,在当前目录下输入:

1
> nodemon app.js

输出字符串

1 2 3 4 5 6 7 8
[nodemon] 1.18.6 [nodemon] to restart at any time, enter `rs` [nodemon] watching: *.* [nodemon] starting `node app.js` Start app. false true [ 'Jonson', 1, 2, 3, 4 ]

修改文件:

1 2 3
var filteredArray = _.uniq(['Jonson',1,'Jonson',1,2,3,4]); 替换为: var filteredArray = _.uniq(['Jonson',1,'Jonson',1]);

自动输出字符串:

1 2 3 4 5 6 7
[nodemon] clean exit - waiting for changes before restart [nodemon] restarting due to changes... [nodemon] starting `node app.js` Start app. false true [ 'Jonson', 1 ]
  • 本文链接: 

  • 版权声明: 本博客所有文章除特别声明外,均采用  许可协议。转载请注明出处!

image.png