【问题标题】:Gulp failed to locate@import file nib.styleGulp 无法定位@import 文件 nib.style
【发布时间】:2015-12-14 13:22:54
【问题描述】:

我收到以下错误

 failed to locate@import file nib.style

当尝试使用 gulp 编译 .styl 文件时

知道怎么解决吗?

gulp.task('flat', function () {
    gulp.src(['**/*.styl', '!**/**mixins**.styl', '!**/**variables**.styl'])
      .pipe(stylus())
      .pipe(gulp.dest('test/'));
});


{
    "dependencies": {
        "bower": "~1.4.1",
        "gulp": "~3.9.0",
        "gulp-complexity": "~0.3.0",
        "gulp-connect": "~2.2.0",
        "gulp-jscs": "~2.0.0",
        "gulp-jscs-stylish": "~1.1.2",
        "gulp-jshint": "~1.11.2",
        "gulp-sloc": "~1.0.4",
        "gulp-util": "~3.0.6",
        "gulp-stylus": "~2.1.1",
        "jshint-stylish": "~2.0.1",
        "open": "~0.0.5",
        "stylus": "~0.52.4",
        "nib": "~1.1.0"
    },
    "name": "app",
    "private": true,
    "version": "0.0.0"
}

【问题讨论】:

    标签: javascript gulp stylus


    【解决方案1】:

    你必须在你的任务中导入 nib:

    var nib = require( 'nib' );
    

    而且你还需要告诉手写笔使用它:

    gulp.src( [ '**/*.styl', '!**/**mixins**.styl', '!**/**variables**.styl' ] )
      .pipe( stylus( { use: [ nib() ] } ) )
      .pipe( gulp.dest( 'test/' ) );
    });
    

    【讨论】:

      【解决方案2】:

      您需要告诉gulp-stylus 使用nib

      var nib = require('nib')();
      
      ...
      .pipe(stylus({ use : nib }))
      ...
      

      【讨论】:

        【解决方案3】:

        我能够解决我的问题,在 gulp 文件中包含 nib,如 this article 中所述。

        var stylus = require('gulp-stylus');
        var nib = require('nib');
        
        gulp.task('flat', function () {
          gulp.src(['themes/**/*.styl', '!themes/**/**mixins**.styl', '!themes/**/**variables**.styl'])
          .pipe(stylus({
            compress: true,
            use: nib()
          }))
          .pipe(gulp.dest('test/'));
        });
        

        【讨论】:

          猜你喜欢
          • 2015-02-27
          • 1970-01-01
          • 1970-01-01
          • 2013-08-29
          • 1970-01-01
          • 2023-03-09
          • 1970-01-01
          • 2015-07-31
          • 2014-01-24
          相关资源
          最近更新 更多