Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript grunt contrib imagemin任务上的travis ci生成失败(无法准备未定义的属性“contents”)_Javascript_Gruntjs_Travis Ci_Grunt Contrib Imagemin - Fatal编程技术网

Javascript grunt contrib imagemin任务上的travis ci生成失败(无法准备未定义的属性“contents”)

Javascript grunt contrib imagemin任务上的travis ci生成失败(无法准备未定义的属性“contents”),javascript,gruntjs,travis-ci,grunt-contrib-imagemin,Javascript,Gruntjs,Travis Ci,Grunt Contrib Imagemin,我在为grunt contrib imagemin任务构建travis ci时遇到错误 Warning: Running "imagemin:dist" (imagemin) task Fatal error: Cannot read property 'contents' of undefined grunt构建在我的本地机器上成功运行,但在通过travis ci执行时失败 Grunfile.js Travis CI grunt生成输出 我试图确定在任务中如何声明src是否存在语法问

我在为grunt contrib imagemin任务构建travis ci时遇到错误

Warning: Running "imagemin:dist" (imagemin) task
    Fatal error: Cannot read property 'contents' of undefined
grunt构建在我的本地机器上成功运行,但在通过travis ci执行时失败

Grunfile.js

Travis CI grunt生成输出

我试图确定在任务中如何声明src是否存在语法问题……但是,情况似乎并非如此……因为我可以使用几种不同的语法样式在本地成功完成构建,而不会出错,包括Grunt为Grunt contrib imagemin提供的示例

参考:

有什么想法或建议吗?

作为后续

我已通过一个简单的解决方法成功地解决了此问题,将grunt contrib imagemin:^1.0.0替换为grunt image:^1.2.1…并随后通过将imagemin任务替换为image任务来更新我的GrunFile.js

本地构建和Travis CI构建现在都取得了相同的结果

Grunfile.js

这个带有grunt image的解决方案正在我的Angular+Firebase应用程序上工作……我正在通过travis ci和部署工具dpl将其部署到Firebase主机上

但是,我还没有确定travis ci中grunt contrib imagemin的原始错误/问题的解决方案

任何想法都将不胜感激。干杯

删除节点单元模块

将package.json更改为使用grunt contrib imagemin:1.0.0和乙烯基fs:2.3.1

是否安装npm
imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
Running "imagemin:dist" (imagemin) task
    Minified 9 images (saved 77.32 kB)

    Done, without errors.

    Execution Time (2016-01-13 17:04:49 UTC)
    imagemin:dist  1.6s  100%
    Total 1.6s
Warning: Running "imagemin:dist" (imagemin) task
    Fatal error: Cannot read property 'contents' of undefined


    Execution Time (2016-01-13 17:00:32 UTC)
    loading tasks    9ms   2%
    imagemin:dist  441ms  98%
    Total 450ms Use --force to continue.

        Aborted due to warnings.
dynamic: {                         // Another target
      files: [{
        expand: true,                  // Enable dynamic expansion
        cwd: 'src/',                   // Src matches are relative to this path
        src: ['**/*.{png,jpg,gif}'],   // Actual patterns to match
        dest: 'dist/'                  // Destination path prefix
      }]
image: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
Running "image:dist" (image) task
✔ app/images/npmjs.png -> before=3.75 kB after=158 B reduced=3.59 kB(95.9%)
✔ app/images/bootstrap.png -> before=41.5 kB after=21.93 kB reduced=19.57 kB(47.2%)
✔ app/images/bowerjs.png -> before=17.71 kB after=6.65 kB reduced=11.06 kB(62.5%)
✔ app/images/nodejs.png -> before=8.45 kB after=2.93 kB reduced=5.51 kB(65.3%)
✔ app/images/starterlog.png -> before=34.53 kB after=10.58 kB reduced=23.95 kB(69.3%)
✔ app/images/gruntjs.png -> before=84.38 kB after=27.98 kB reduced=56.4 kB(66.8%)
✔ app/images/firebase.png -> before=32.03 kB after=12.19 kB reduced=19.83 kB(61.9%)
✔ app/images/fontawesome.png -> before=12.01 kB after=5.63 kB reduced=6.38 kB(53.1%)
✔ app/images/angular.png -> before=41.5 kB after=18.63 kB reduced=22.87 kB(55.1%)

Done, without errors.

Execution Time (2016-01-13 17:47:44 UTC)
image:dist  2.6s  99%
Total 2.6s