星期四, 9月 11, 2014

[Gulp 問題] “Possibly unhandled Error: path should be string...” when gulp build

不知怎搞的,才剛 build 沒事,緊接著改了無關緊要的 code,就出現了如下的錯誤訊息:
indiana@indiana-dt:.../program/web/my-project$ gulp build
[10:52:54] Using gulpfile ~/program/web/my-project/gulpfile.js
[10:52:54] Starting 'styles'...
[10:52:54] Starting 'scripts'...
[10:52:54] Starting 'images'...
[10:52:54] Starting 'fonts'...
[10:52:55] Starting 'extras'...
[10:52:55] Starting 'move'...
/home/indiana/program/web/my-project/app/scripts/facebook.js
  line 46  col 9   'alert' is not defined.
  line 63  col 50  'params' is defined but never used.
  line 82  col 52  'widget' is defined but never used.
  line 82  col 46  'href' is defined but never used.
✖ 4 problems
Possibly unhandled Error: path should be string
    at File.Object.defineProperty.set (/home/indiana/program/web/my-project/node_modules/gulp/node_modules/vinyl-fs/node_modules/vinyl/index.js:166:41)
    at Function.assign (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/lodash-node/modern/objects/assign.js:63:21)
    at /home/indiana/program/web/my-project/node_modules/gulp-cache/lib/TaskProxy.js:20:19
    at tryCatch1 (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/util.js:64:19)
    at Promise$_callHandler [as _callHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:708:13)
    at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:724:18)
    at Promise$_settlePromiseAt [as _settlePromiseAt] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:896:14)
    at Promise$_fulfillPromises [as _fulfillPromises] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:1041:14)
    at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:64:12)
    at Async$consumeFunctionBuffer (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:37:14)
Possibly unhandled Error: path should be string
    at File.Object.defineProperty.set (/home/indiana/program/web/my-project/node_modules/gulp/node_modules/vinyl-fs/node_modules/vinyl/index.js:166:41)
    at Function.assign (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/lodash-node/modern/objects/assign.js:63:21)
    at /home/indiana/program/web/my-project/node_modules/gulp-cache/lib/TaskProxy.js:20:19
    at tryCatch1 (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/util.js:64:19)
    at Promise$_callHandler [as _callHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:708:13)
    at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:724:18)
    at Promise$_settlePromiseAt [as _settlePromiseAt] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:896:14)
    at Promise$_fulfillPromises [as _fulfillPromises] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/promise.js:1041:14)
    at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:64:12)
    at Async$consumeFunctionBuffer (/home/indiana/program/web/my-project/node_modules/gulp-cache/node_modules/bluebird/js/main/async.js:37:14)

[10:52:55] gulp-size: total 19.5 kB
[10:52:55] Finished 'scripts' after 864 ms
[10:52:55] Finished 'move' after 234 ms
[10:52:55] gulp-size: total 699.12 kB
[10:52:55] Finished 'fonts' after 421 ms
[10:52:55] Finished 'extras' after 258 ms
npm WARN package.json wifi@0.0.0 No description
npm WARN package.json wifi@0.0.0 No repository field.
npm WARN package.json wifi@0.0.0 No README data
[10:52:56] gulp-size: total 130.39 kB
[10:52:56] Finished 'styles' after 2.24 s
[10:52:56] Starting 'html'...
[10:53:15] gulp-size: total 2.08 MB
[10:53:15] Finished 'html' after 19 s
indiana@indiana-dt:.../program/web/my-project$ 

參考文件: https://github.com/jgable/gulp-cache/issues/24

原因是在 package ‘imagemin’ 運作時 cache 出現了問題造成的,只要在 gulpfile.js 中加入清除 cache 的指令就可以了。
gulpfile.js:
'use strict';
// generated on 2014-08-25 using generator-gulp-webapp 0.1.0
var gulp = require('gulp');
// load plugins
var $ = require('gulp-load-plugins')();
$.cache.clearAll();
var mainBowerFiles = require('main-bower-files');

...

0 意見: