gpt4 book ai didi

ubuntu - TypeError : gulp. 运行不是函数

转载 作者:行者123 更新时间:2023-12-04 19:08:07 24 4
gpt4 key购买 nike

我计划备份/镜像我的 linux 主目录中的所有文件。
首先我在这里读到:Skip local installation of Gulp
我在我的 Linux 主目录中安装了所有内容:

sudo apt install npm
sudo npm install --global gulp-cli
npm link gulp
npm init
$ gulp
[07:32:43] Using gulpfile ~/gulpfile.js
[07:32:43] Starting 'default'...
[07:32:43] Finished 'default' after 1.24 ms
如果发生更改,它会启动、等待并在每次发生错误时发送:
类型错误:gulp.run 不是函数
var gulp = require('gulp');
gulp.task('backupHomeDir', function () {
return gulp.src('./*.js') // read all of the files that are in js with a .js extension
// .pipe(gulp.dest('dist/js')); // write to the dist/js file
.pipe(gulp.dest('/media/m/sdd2 ntfs/backup/home/'));
});
gulp.task('default', function () {
// watch for changes
gulp.watch('./*.js', function () {
gulp.run('backupHomeDir');
});
});
我可以开始
$ sudo gulp
或者
$ gulp
错误是一样的:
[12:32:19] Using gulpfile /home/m/gulpfile.js
[12:32:19] Starting 'default'...
[12:33:09] Starting '<anonymous>'...
[12:33:09] '<anonymous>' errored after 1.08 ms
[12:33:09] TypeError: gulp.run is not a function
at /home/m/gulpfile.js:22:12
at bound (domain.js:402:14)
at runBound (domain.js:415:12)
at asyncRunner (/usr/local/lib/node_modules/gulp/node_modules/async-done/index.js:55:18)
at process._tickCallback (internal/process/next_tick.js:61:11)
```

最佳答案

第一次重制npm i .
第二个 gulp.run 已弃用,您只需使用 gulp.watch()并将任务数组设置为第二个参数而不是回调,在您的情况下:

gulp.watch('./*.js', ['default','backupHomeDir']);
完全的:
var gulp = require('gulp');
gulp.task('default', function () {
return gulp.src('./*.js') // read all
.pipe(gulp.dest('/media/m/sdd2 ntfs/backup/home/'));
});
gulp.watch('./*.js', gulp.series('default'));

关于ubuntu - TypeError : gulp. 运行不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64087553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com