【问题标题】:nodemon clean exit - waiting for changes before restartnodemon clean exit - 在重启前等待更改
【发布时间】:2021-05-15 14:20:10
【问题描述】:

我正在为基于打字稿的快递服务器开发样板。我的关键要求之一是让 eslint 与 nodemon 一起运行。在我的 package.json 我有...

"scripts": {
    "start": "node dist/index.js",
    "dev": "nodemon src/index.ts --exec 'eslint . --ext .ts'",
    "build": "tsc -p ."
},

此时我的快递应用程序非常简单......

import express from 'express';
import { PORT } from './config/constants';

const app = express();
app.use(express.json());

app.get('/api-v1', (req, res) => {
    const test = 3;
    console.log(test);
    res.send('Hello World');
});

app.listen(PORT, () => {
    console.log(`Server is listening on port ${PORT}`);
});

所以当我运行开发脚本"nodemon src/index.ts --exec 'eslint . --ext .ts'" 时,linting 会运行,但是 express 服务器从未启动...我在控制台中看到了这一点:

[nodemon] clean exit - waiting for changes before restart

关于如何解决此问题的任何想法?

【问题讨论】:

    标签: javascript typescript express nodemon


    【解决方案1】:

    源码是here

    我想nodemon 期望运行一个服务器(它永远不会退出),但命令以代码 0 退出(这是成功退出代码)。

    好像nodemon 调用不正确。

    它当前运行eslint . --ext .ts src/index.ts(成功运行并以代码0退出)。

    我认为应该是这样的(其他选项请参见this answer):

    "scripts": {
        "start": "node dist/index.js",
        "dev": "tsc-watch --project . --outDir ./dist --onSuccess \"nodemon dist/index.js\"",
        "build": "tsc -p ."
    },
    

    【讨论】:

      猜你喜欢
      • 2020-11-07
      • 2022-01-20
      • 2022-01-15
      • 2018-04-29
      • 2017-10-15
      • 2016-09-25
      • 2021-09-04
      • 2021-05-31
      • 1970-01-01
      相关资源
      最近更新 更多