'gulp.dest() is not creating an output file

I have the following code in a gulp task. It's not writing an output file.

  const player = {
    player: {
      src: 'x',
      tpl: '<style>%s</style>'
    }
  }
  gulp.src('.src/index.html')
    .pipe(replace(player))
    .pipe(gulp.dest('./app/));


Solution 1:[1]

This has one of those 'well duh' answers. You've left a slash out of your source path. It should be ./src/index.html. Since gulp.src() doesn't throw an error, it doesn't occur to you to check it.

Solution 2:[2]

There are two issues in your code.


1. Incorrect path

Your first mistake is that you have gotten an incorrect path.

In the gulp.src() function, you are passing a path to a folder called .src. However, it is most likely supposed to be redirecting to ./src. See the code below for the solution.

gulp.src("./src/index.html");

2. Missing end quote (")

Your other mistake is that you've forgotten to end your string in the .pipe() method (the second one).

The code below should work properly.

.pipe("./app/");

In conclusion, there were two issues in your code.

  1. Incorrect path
  2. Missing end quote (")

When these two are fixed, your code should run correctly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StormyKnight
Solution 2 Arnav Thorat