【问题标题】:gulp-nodemon watch typescript filesgulp-nodemon 监视打字稿文件
【发布时间】:2017-03-08 15:00:11
【问题描述】:

我有 2 个目录:

  • 应用es5 javascript files compiled by gulp task

  • src typescript source files

我想在 src/ 目录中的任何更改上从 app/ 重新启动 nodemon make start 脚本。但它不起作用 - 应用程序刚刚启动,但 nodemon 不会对更改进行任何重新加载。 (貌似没看src/)

这是我的gulpfile:

var gulp = require("gulp-help")(require("gulp")),
    ts = require("gulp-typescript"),
    nodemon = require("gulp-nodemon");

/***********************************************************************************
 * Build es5 javascript files from typescript sources
 ***********************************************************************************/
gulp.task("compile", function() {
    var project = ts.createProject({
        "target": "ES5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "noImplicitAny": false
    });
    return gulp.src("./src/**/*.ts")
        .pipe(project())
        .pipe(gulp.dest("./app/"))
});

/***********************************************************************************
 * Call "build" task and start nodemon with watch (autorestart on changes found)
 ***********************************************************************************/
gulp.task("default", ["compile"], function() {
    var stream = nodemon({
        script: "app/",
        watch: "src",
        tasks: ["compile"],
        env: { "DEBUG": "Application,Request,Response" }
    });
    return stream;
});

【问题讨论】:

  • 你可以使用 gulp.watch, imo

标签: javascript node.js typescript gulp nodemon


【解决方案1】:

在提供的代码中,您缺少脚本的起始文件:

以下script: "app/" 需要指定为实际文件而不是目录。

例如:

注意:确保您使用的是编译后的 .js 文件,而不是 nodemon 服务器的 .ts 文件。

script : 'app.js'

或者您可以设置路径以确保您在正确的位置。

script : 'app/app.js

这是做什么的,它使用指定的文件启动服务器。如果这不起作用,我建议查看您的文件结构,特别是 gulpfile.js 文件所在的位置。根据位置,您可能没有使用正确的路径。

【讨论】:

    【解决方案2】:

    对于 perl 和 chmod 选项,您必须将 mysql 用于 php 和 grub 部分

    【讨论】:

      猜你喜欢
      • 2016-07-22
      • 2015-01-24
      • 1970-01-01
      • 2021-12-12
      • 2019-02-20
      • 2014-12-11
      • 1970-01-01
      • 2018-09-25
      • 1970-01-01
      相关资源
      最近更新 更多