gulpjs / gulpjs/gulp

Gulp throws error `Can only pipe to one destination`

Open
#2,820 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
32.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### What were you expecting to happen?
The gulp task should be executed successfully.

### What actually happened?
Gulp is throwing the below error
```
Can only pipe to one destination
```

### Sample code

```js
function generateHTML(path, withStyles) {
let stream = src(path.html.src, {
base: '.',
});

if (argv.production) {
stream = minifyHTMLReferences(stream, withStyles);
}

stream.pipe(dest(path.html.dest));
return stream;
}
const gulpWatch = series(
generateHTML
...othertask
)
export { gulpWatch as watch }
```

### Terminal output / screenshots

```sh
$ gulp watch
```
output
```sh
Error: Can only pipe to one destination
at ReadableState.pipe (path-to-node_modules/node_modules/streamx/index.js:260:13)
at Transform.pipe (path-to-node_modules/node_modules/streamx/index.js:722:25)
at resumer (path-to-node_modules/node_modules/stream-exhaust/index.js:12:12)
at asyncRunner (path-to-node_modules/node_modules/async-done/index.js:65:11)
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
```

### Please provide the following information:
* OS & version: MacOS Sonoma 14.3.1
* node version: v20.17.0
* npm version: 10.8.2
* gulp version: 5.0.0

### Additional information
The below code works but when `dest` is set after creating stream, the task fails
```js
function generateHTML(path, withListViewStyles) {
return src(path.html.src, {
base: '.',
}).pipe(dest(path.html.dest));

}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.