【问题标题】:How do I use nodemon for both eslint and babel如何将 nodemon 用于 eslint 和 babel
【发布时间】:2018-12-19 23:27:44
【问题描述】:

我有一些如下所示的启动脚本:

"nodemonBabel": "nodemon src/index.js --exec babel-node",
"nodemonLint": "nodemon src/index.js --exec 'npm run lint && node'" 

我在 cli 中使用 npm run nodemonBabel 来查看我的代码 nodemon 并触发 Babel 在代码更改时对其进行转译。我还使用npm run nodemonLintnodemon 一起观看,同时在代码更改时触发eslint

如何将两个脚本合并为一行?即,使用 nodemon 监视我的代码,使用 Babel 从单个脚本中进行 lint 和 transpile,而我不必为每次更改都重新运行?

【问题讨论】:

标签: node.js npm babeljs eslint nodemon


【解决方案1】:

您要做的是同时运行两个脚本,请参见此处:How can I run multiple npm scripts in parallel?

使用名为 concurrently 的包。

npm i concurrently --save-dev

然后设置您的npm run dev 任务:

"dev": "concurrently --kill-others \"npm run nodemonBabel\" \"npm run nodemonLint\""

【讨论】:

    猜你喜欢
    • 2016-05-27
    • 2021-10-29
    • 2019-10-23
    • 2019-09-12
    • 2016-09-14
    • 2019-08-06
    • 1970-01-01
    • 2017-12-08
    • 2019-08-05
    相关资源
    最近更新 更多