gulp:"TypeError:打印不是函数"; [英] gulp : "TypeError: print is not a function"

查看:130
本文介绍了gulp:"TypeError:打印不是函数";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gulp在目录中构建Semantic-UI,但是出现这些错误:

I am trying to build Semantic-UI with gulp in a directory, but I get having these errors :

root@ks4000003:/var/www/mg.guylabbe.ca/web/inc/semantic# gulp build
[10:36:53] Using gulpfile /var/www/clients/client1/web179/web/inc/semantic/gulpfile.js
[10:36:53] Starting 'build'...
Building Semantic
[10:36:53] Starting 'build-javascript'...
Building Javascript
[10:36:54] 'build-javascript' errored after 19 ms
[10:36:54] TypeError: print is not a function
    at Gulp.module.exports (/var/www/clients/client1/web179/web/inc/semantic/tasks/build/javascript.js:64:11)
    at module.exports (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/var/www/clients/client1/web179/web/inc/node_modules/run-sequence/index.js:124:15)
    at runSequence (/var/www/clients/client1/web179/web/inc/node_modules/run-sequence/index.js:136:2)
    at Gulp.module.exports (/var/www/clients/client1/web179/web/inc/semantic/tasks/build.js:49:3)
    at module.exports (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:273:3)
[10:36:54] 'build' errored after 21 ms
[10:36:54] TypeError in plugin "run-sequence(build-javascript)"
Message:
    print is not a function
Stack:
TypeError: print is not a function
    at Gulp.module.exports (/var/www/clients/client1/web179/web/inc/semantic/tasks/build/javascript.js:64:11)
    at module.exports (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:134:8)
    at runNextSet (/var/www/clients/client1/web179/web/inc/node_modules/run-sequence/index.js:124:15)
    at runSequence (/var/www/clients/client1/web179/web/inc/node_modules/run-sequence/index.js:136:2)
    at Gulp.module.exports (/var/www/clients/client1/web179/web/inc/semantic/tasks/build.js:49:3)
    at module.exports (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/var/www/clients/client1/web179/web/inc/node_modules/orchestrator/index.js:273:3)

如果我检查javascript.js文件,则正确加载了gulp-print:

If I check javascript.js file, gulp-print is correctly loaded :

var print = require('gulp-print');

并使用(下面的第8行):

and used (8th line below) :

  // copy source javascript
  gulp.src(source.definitions + '/**/' + globs.components + '.js')
    .pipe(plumber())
    .pipe(flatten())
    .pipe(replace(comments.license.in, comments.license.out))
    .pipe(gulp.dest(output.uncompressed))
    .pipe(gulpif(config.hasPermission, chmod(config.permission)))
    .pipe(print(log.created))
    .pipe(uglify(settings.uglify))
    .pipe(rename(settings.rename.minJS))
    .pipe(gulp.dest(output.compressed))
    .pipe(gulpif(config.hasPermission, chmod(config.permission)))
    .pipe(print(log.created))
    .on('end', function() {
      gulp.start('package compressed js');
      gulp.start('package uncompressed js');
      callback();
    })
  ;

Gulp版本:

[10:42:25] CLI version 3.9.1
[10:42:25] Local version 3.9.1

有人对这个问题有想法吗? 谢谢!

Does anybody has thoughts on this problem? Thank you!

推荐答案

gulpPrint函数是默认导出,因此,在导入gulp依赖项时需要添加一些代码.替换:

gulpPrint function is default export, therefore, I need to add a bit of code while importing gulp dependencies. Replace :

var print        = require('gulp-print');

作者:

var print        = require('gulp-print').default;
// usage
print();

所以gulpPrint();函数重命名为print();

so the gulpPrint(); function is renamed print();

或也可以通过以下方式使用:

or can also be used in the following way:

var print = require('gulp-print');
// usage
print.default()

例如,如有疑问,请使用console.log(print)转储变量内容.如果您是像我这样的初学者,则对理解其背后的逻辑将有很大帮助.

In case of doubt, dump variable contents with console.log(print), for instance. It will help a lot to understand the logic behind it if you are a beginner like me.

这篇关于gulp:"TypeError:打印不是函数";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆