Gulp错误 - 错误:找不到模块'sigmund'

3

在安装了browser-sync后,我的Gulp正常工作,但是我遇到了这个错误:

错误:找不到模块'lru-cache'

我通过https://github.com/npm/npm/issues/1154中的npm link lru-cache解决了这个问题。

然而,现在当我尝试运行gulp时,我又遇到了这个新的错误:

~/Projects/starfeeder ❯ npm install browser-sync gulp --save-dev npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

fsevents@1.1.2 install /Users/leongaban/Projects/starfeeder/node_modules/fsevents node install

如果有帮助,这是我的gulpfile:

"use strict";
const gulp        = require('gulp'),
      _           = require('lodash'), // https://www.npmjs.com/package/lodash
      del         = require('del'), // https://www.npmjs.com/package/del
      fs          = require('fs'), // Node file system
      gutil       = require('gulp-util'), // https://www.npmjs.com/package/gulp-util
      htmlReplace = require('gulp-html-replace'), // https://www.npmjs.com/package/gulp-html-replace
      notify      = require("gulp-notify"), // https://www.npmjs.com/package/gulp-notify
      runSequence = require('run-sequence'), // https://www.npmjs.com/package/run-sequence
      sass        = require('gulp-ruby-sass'), // https://www.npmjs.com/package/gulp-ruby-sass
      sourcemaps  = require('gulp-sourcemaps'); // https://www.npmjs.com/package/gulp-sourcemaps

const rootPath = process.cwd();

const paths = {
    files: ['src/static/**']
};

const errorlog = err => {
    gutil.log(gutil.colors.red.bold.inverse('  ERROR: '+err));
    this.emit('end');
};

// Build tasks chain ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
gulp.task('build', function(cb) {
    runSequence(
        'build:app-css',      // Minify and concat app styles
        'build:move-files',
        'build:index',        // Replace scripts in index.html
        'build:final', cb);   // Remove app.min.js from build folder
});

gulp.task('build:move-files', () => gulp.src(paths.files).pipe(gulp.dest('starfeeder/')) );

// Preprocess SASS into CSS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
gulp.task('build:app-css', () => sass('src/sass/starfeeder.scss', { style: 'compressed' }).on('error', errorlog).pipe(gulp.dest('src/static/css/')) );

// Clear out all files and folders from build folder \\\\\\\\\\\\\\\\\\\\\\\\\\\
gulp.task('build:cleanfolder', cb => { del(['starfeeder/**'], cb); });

// Task to make the index file production ready \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
gulp.task('build:index', () => {
    process.stdout.write(gutil.colors.white.inverse(' New asset paths in markup: \n'));
    process.stdout.write(gutil.colors.yellow(' static/css/starfeeder.css\n'));

    gulp.src('index.html')
        .pipe(htmlReplace({
            'app-css': 'css/starfeeder.css'
        }))
        .pipe(gulp.dest('starfeeder/'))
        .pipe(notify('Starfeeder build created!'));
});

gulp.task('build:final', cb => {
    process.stdout.write(gutil.colors.blue.bold   ('######################################################     \n'));
    process.stdout.write(gutil.colors.blue.inverse('               Starfeeder build created!                   \n'));
    process.stdout.write(gutil.colors.blue.bold   ('######################################################     \n'));
});

// Main Styles /////////////////////////////////////////////////////////////////
gulp.task('app-css', () => {
    return sass('src/sass/starfeeder.scss', { style: 'compressed' })
    .pipe(sourcemaps.init())
    .on('error', errorlog)
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest('src/static/css/'))
});

// Development watch /////////////////////////////////////////////////////////// ☕️⏎→
gulp.task('watch', () => {
    gulp.watch('src/sass/**/*.scss', ['app-css']).on('change', file => {
        let filePath = file.path.split(rootPath);
        logFileChanged(filePath[1]);
    });
});

gulp.task('default', ['watch']);

1
你尝试过升级你的 gulp 吗? - lumio
我刚刚安装了最新版的gulp,但是现在才让它重新工作起来...真是太奇怪了,下面是我发现的内容。 - Leon Gaban
2个回答

2

我曾经在安装through2时遇到过相同的问题。该项目使用了缩小包并且有一个package-lock.json,这导致依赖关系中断。一旦我删除了锁定文件并重新安装,一切都很好。


1

好的,我仍然不确定为什么会出现这些错误,但是我再也不会安装browserSync了。

我不得不对我的所有gulp插件进行npm link

这个方法可以工作,但在gulp build过程中却出了问题。

我不再对所有东西都进行npm link,而是包括了一些我从未听说过的其他node模块。我删除了browserSync并删除了我的node_modules文件夹,然后执行了yarn(npm) install


啊,我也遇到过类似的问题。很高兴知道 browserSync 可能会导致这些奇怪的缓存错误。 - lumio
不是browserSync的问题。我通过through2安装时也出现了同样的情况。 - dman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接