【发布时间】:2018-03-11 14:50:01
【问题描述】:
我正在尝试在目录中使用 gulp 构建 Semantic-UI,但出现以下错误:
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 已正确加载:
var print = require('gulp-print');
并使用(以下第 8 行):
// 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
有人对这个问题有想法吗? 谢谢!
【问题讨论】:
-
看起来 gulp-print 可以接受一个返回字符串的函数。 log.created 是一个函数吗?它不能是字符串。但如果这是你想要的,很容易改变。也许这是您错误的根源。
-
谢谢@Mark;即使您的评论不是对我的问题的直接回答,这确实鼓励我查找变量(使用 console.log() 打印它们)。查看 gulp-print 有助于理解我必须稍微编辑代码。我将编写解决方案作为答案。但这仍然很奇怪,因为这不是自定义脚本。
-
嗯,那个插件很不标准!尝试解决此问题的用户请参阅github.com/alexgorbatchev/gulp-print/issues/20。我没有找到你的解决方法,因为我从来没有为 gulp 插件这样做过。
-
我在搜索时没有遇到这个...非常感谢!他们正在使用与我建议的解决方案类似的解决方案(可能更好一点,呵呵)
标签: javascript npm gulp semantic-ui gulp-print