如何将 GULP 任务拆分为多个文件



我有一个gulp文件夹,里面有这个gulpfile.js

const source = require('vinyl-source-stream');
const gulp = require('gulp');
module.exports = function(args) {
gulp.task('default', function() {});
}

我有一个包含此projectgulpfile.js的文件夹

const projectGulp = require('../gulp/gulpfile.js')
projectGulp();

project文件夹中,我有一个package.json,其中添加了vinyl-source-stream作为开发依赖项,现在我在此文件夹上运行yarn install

当我运行gulpCannot find module vinyl-source-stream出现错误。

如果我对文件夹gulp并执行yarn install vinyl-source-stream它工作正常。现在我得到Task default is not in your gulpfile错误。

我建议执行以下操作:

$ yarn install --check-files

--check-files标志验证是否未从文件夹中删除node_modules包。(请参阅纱线文档)。

如果它不起作用,您应该尝试:

$ rm -rf ./node_modules/
$ npm cache clean
$ npm install

然后可能会看看vinyl-source-stream是否在它应该在的地方:

$ ls ./node_modules/vinyl-source-stream

由于我主要在Windows上工作,因此我遇到了所有可能的纱线错误。我曾经遇到过与此类似的问题,这就是简单地删除所有内容并调用 npm 会有所帮助的情况。纱线有时无法弄清楚缺少依赖关系,尤其是 gulp。

最新更新