【问题标题】:why grunt is failing at imagemin dependency?为什么 grunt 在 imagemin 依赖方面失败了?
【发布时间】:2015-12-27 19:35:31
【问题描述】:

我使用的是节点版本 0.12.2 和 npm 版本 3.3.6。我正在使用 yeoman 工具来创建 Angular 应用程序。当我运行 grunt 时,它在 imagemin 依赖项中中止。我也尝试了命令npm install -g grunt-contrib-imageminnpm install imagemin。我仍然面临同样的错误:

Execution Time (2015-12-27 19:17:59 UTC)
    loading tasks          87ms  ▇▇ 3%
    loading grunt-svgmin     2s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 75%
    svgmin:dist           566ms  ▇▇▇▇▇▇▇▇▇ 21%
    Total 2.6s
        Warning: Running "imagemin:dist" (imagemin) task
    Fatal error: Cannot read property 'contents' of undefined
     Aborted due to warnings.

这是我的 package.json:

{
  "name": "cordapp",
  "private": true,
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-angular-templates": "^0.5.7",
    "grunt-autoprefixer": "^2.0.0",
    "grunt-concurrent": "^1.0.0",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-concat": "^0.5.0",
    "grunt-contrib-connect": "^0.9.0",
    "grunt-contrib-copy": "^0.7.0",
    "grunt-contrib-cssmin": "^0.12.0",
    "grunt-contrib-htmlmin": "^0.4.0",
    "grunt-contrib-imagemin": "^0.9.2",
    "grunt-contrib-jshint": "^0.11.0",
    "grunt-contrib-uglify": "^0.7.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-filerev": "^2.1.2",
    "grunt-google-cdn": "^0.4.3",
    "grunt-karma": "*",
    "grunt-newer": "^1.1.0",
    "grunt-ng-annotate": "^0.9.2",
    "grunt-svgmin": "^2.0.0",
    "grunt-usemin": "^3.0.0",
    "grunt-wiredep": "^2.0.0",
    "jit-grunt": "^0.9.1",
    "jshint-stylish": "^1.0.0",
    "karma-jasmine": "*",
    "karma-phantomjs-launcher": "*",
    "time-grunt": "^1.0.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }
}

任何帮助将不胜感激。

【问题讨论】:

  • 查看更新到最新版本的 Node(版本 4.2.X)是否有所不同。另外,如果您使用的是 Windows 机器,在执行 npm install 时,您是否收到类似 pre-build test failed 的错误?

标签: gruntjs npm yeoman yeoman-generator-angular grunt-contrib-imagemin


【解决方案1】:

清理你的 npm cash 并重新安装 grunt-contrib-imagemin

npm cache clean && npm install grunt-contrib-imagemin

【讨论】:

猜你喜欢
  • 2015-10-06
  • 2013-01-19
  • 1970-01-01
  • 2018-08-02
  • 2014-06-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-16
  • 2012-09-16
相关资源
最近更新 更多