代码之家  ›  专栏  ›  技术社区  ›  Friso

Nodemon-w继续启动,而不运行服务器

  •  0
  • Friso  · 技术社区  · 6 年前

    当我跑的时候 nodemon dist/index.js nodemon运行服务器,但是如果我使用 nodemon -w dist/index.js ,它只是继续启动,而没有真正运行我的服务器。

    我从Typescript中导出index.js文件,如下所示:

    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const App_1 = require("./App");
    const port = process.env.PORT || 3000;
    App_1.default.listen(port, (err) => {
        if (err) {
            return console.log(err);
        }
        return console.log(`server is listening on ${port}`);
    });
    //# sourceMappingURL=index.js.map
    

    据我所知,在使用 tsc -b 命令。

    是什么原因导致nodemon继续启动?我该怎么解决呢?

    1 回复  |  直到 6 年前
        1
  •  1
  •   AleÅ¡ Dostál    6 年前

    用nodemon更好的是使用ts节点。这个库有利于开发,因为使用ts lint可以运行TypeScript文件。

    nodemon.json ```

    {
        "watch": ["server/**/*.ts"],
        "execMap": {
            "ts": "ts-node"
        }
    }
    

    ```

    包.json "dev": "nodemon server/index.ts"