首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gulp:"TypeError:打印不是函数“

gulp:"TypeError:打印不是函数“
EN

Stack Overflow用户
提问于 2018-03-11 14:50:01
回答 2查看 7.2K关注 0票数 7

我试图在目录中使用gulp构建语义-UI,但我遇到了以下错误:

代码语言:javascript
复制
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:

代码语言:javascript
复制
var print = require('gulp-print');

并使用(下面第8行):

代码语言:javascript
复制
  // 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();
    })
  ;

吞咽版:

代码语言:javascript
复制
[10:42:25] CLI version 3.9.1
[10:42:25] Local version 3.9.1

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-03-12 17:52:52

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

代码语言:javascript
复制
var print        = require('gulp-print');

通过:

代码语言:javascript
复制
var print        = require('gulp-print').default;
// usage
print();

因此,gulpPrint();函数被重命名为print();

也可以以下列方式使用:

代码语言:javascript
复制
var print = require('gulp-print');
// usage
print.default()

如果有疑问,可以使用console.log(打印)转储变量内容。如果你像我一样是初学者的话,理解它背后的逻辑会有很大帮助。

票数 9
EN

Stack Overflow用户

发布于 2018-10-31 22:42:39

第一个答案中描述的变化已经出现在语义ui guilpfile.js中。但是,在运行gulp时,我也遇到了同样的错误。

其原因是旧版本的吞咽打印。在更新了最新版本后,gulp就已经很好了:

代码语言:javascript
复制
npm install gulp-print@5.0.0 --save-dev
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49221304

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档