【问题标题】:how to split gulp tasks into multiple files如何将 gulp 任务拆分为多个文件
【发布时间】:2019-04-14 11:10:25
【问题描述】:

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

const source = require('vinyl-source-stream');
const gulp = require('gulp');

module.exports = function(args) {
  gulp.task('default', function() {});
}

我有一个带有gulpfile.jsproject 文件夹

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

projectGulp();

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

当我运行gulp 时,我得到Cannot find module vinyl-source-stream 错误。

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

【问题讨论】:

  • 你的NODE_ENV值是多少?
  • 我没有那个。
  • 试试yarn install --production=false
  • 不,它不起作用

标签: javascript node.js gulp babeljs


【解决方案1】:

我建议您执行以下操作:

  $ yarn install --check-files

--check-files 标志验证是否未从 node_modules 文件夹中删除包。 (见yarn documentation)。

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

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

然后大概看看vinyl-source-stream是不是应该在的地方:

  $ ls ./node_modules/vinyl-source-stream

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 2013-08-24
    相关资源
    最近更新 更多