一份比较常用的在这里
wait-on
wait-on file1 && NEXT_CMD # wait for file1, then exec NEXT_CMDwait-on f1 f2 && NEXT_CMD # wait for both f1 and f2, the exec NEXT_CMDwait-on http://localhost:8000/foo && NEXT_CMD # wait for http 2XX HEADwait-on https://myserver/foo && NEXT_CMD # wait for https 2XX HEADwait-on http-get://localhost:8000/foo && NEXT_CMD # wait for http 2XX GETwait-on https-get://myserver/foo && NEXT_CMD # wait for https 2XX GETwait-on tcp:4000 && NEXT_CMD # wait for service to listen on a TCP portwait-on socket:/path/mysock # wait for service to listen on domain socketwait-on http://unix:/var/SOCKPATH:/a/foo # wait for http HEAD on domain socketwait-on http-get://unix:/var/SOCKPATH:/a/foo # wait for http GET on domain socket
concurrently
"start": "concurrently \"command1 arg\" \"command2 arg\""
log4js
更好的控制台输出,支持记录日志文件。文档在这里,比较详细的介绍在这里
var log4js = require("log4js");var logger = log4js.getLogger();logger.level = "debug";logger.debug("Some debug messages");
一个简单的配置文件如下log4js.config.json
appenders:必须有,键值对形式,定义了使用的输出类型categories:必须有,至少有default键,指定对应appenders输出的等级ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF
nodemon
nodejs监控文件并且热替换
安装npm install -g nodemon
使用nodemon [your node app]
Commander
Node命令行必知必会工具,用来解析命令行。作者TJ Holowaychuk,不知道他你可以不用学前端了。
安装:
链式方法
command:自定义执行的命令
option:可选参数
alias:用于 执行命令的别名
description:命令描述
action:执行命令后所执行的方法
usage:用户使用提示
parse:解析命令行参数,注意这个方法一定要放到最后调用
作者:忍不住的k
链接:https://www.jianshu.com/p/9ff49cb88204
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
fs-extra
node原生模块的替代品,包含了mkdirp、rimraf、ncp并且自带了promisify
安装
npm install fs-extra
//async awaitasync function copyFiles () {try {await fs.copy('/tmp/myfile', '/tmp/mynewfile')console.log('success!')} catch (err) {console.error(err)}}
figlet
酷炫的登陆欢迎语,极客就该有极客的范儿
var figlet = require('figlet');figlet('Hello World!!', function(err, data) {if (err) {console.log('Something went wrong...');console.dir(err);return;}console.log(data)});//_ _ _ _ __ __ _ _ _ _| | | | ___| | | ___ \ \ / /__ _ __| | __| | | || |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | || _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|_||_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_|_)
