webpack 2 用 image-webpack-loader 报错 dyld: Library not loaded

系统参数:
OS El Caption version 10.11.6
MacBook Air (13-inch, Mid 2013)
Node.js: V8.2.1

包参数

使用了 webpack 2,以及处理 jpg 图片的 loader:image-webpack-loader

{
  // ...
  "devDependencies": {
    "babel-core": "6.17.0",
    "babel-loader": "6.2.0",
    "babel-preset-env": "1.1.4",
    "css-loader": "0.26.1",
    "extract-text-webpack-plugin": "2.0.0-beta.4",
    "image-webpack-loader": "3.1.0",
    "style-loader": "0.13.1",
    "url-loader": "0.5.7",
    "webpack": "2.2.0-rc.0"
  }
}

问题

在用 webpack build 过程中报错:缺少 dlyd 即 libpng 库文件。

ERROR in ./assets/small.jpg
Module build failed: Error: dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /Users/macair/Documents/oschina/udm_grider_webpack2/chap3_handle_assets/node_modules/mozjpeg/vendor/cjpeg
  Reason: image not found

    at Promise.all.then.arr (/Users/macair/Documents/oschina/udm_grider_webpack2/chap3_handle_assets/node_modules/execa/index.js:231:11)
    at 
    at process._tickCallback (internal/process/next_tick.js:188:7)
 @ ./src/image_viewer.js 7:13-43
 @ ./src/index.js

解决

安装或者重新安装 MacOS 系统中的 libpng 库即可。

brew install libpng

或者

brew reinstall libpng

参考

Unable to load image files #51

Module build failed: Error: dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib #60

你可能感兴趣的:(webpack 2 用 image-webpack-loader 报错 dyld: Library not loaded)