我有一个gulp
文件夹,里面有这个gulpfile.js
const source = require('vinyl-source-stream');
const gulp = require('gulp');
module.exports = function(args) {
gulp.task('default', function() {});
}
我有一个包含此project
gulpfile.js
的文件夹
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
错误。
我建议执行以下操作:
$ 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。