夜听城嚣 夜听城嚣
首页
  • 学习笔记

    • 《JavaScript高级程序设计》
    • 前端基建与架构
  • 专题分享

    • Git入门与开发
    • 前端面试题汇总
    • HTML和CSS知识点
  • 项目实践
  • 抓包工具
  • 知识管理
  • 工程部署
  • 团队规范
bug知多少
  • 少年歌行
  • 青年随笔
  • 文海泛舟
  • 此事躬行

    • 项目各工种是如何协作的
    • TBA课程学习
收藏

dwfrost

前端界的小学生
首页
  • 学习笔记

    • 《JavaScript高级程序设计》
    • 前端基建与架构
  • 专题分享

    • Git入门与开发
    • 前端面试题汇总
    • HTML和CSS知识点
  • 项目实践
  • 抓包工具
  • 知识管理
  • 工程部署
  • 团队规范
bug知多少
  • 少年歌行
  • 青年随笔
  • 文海泛舟
  • 此事躬行

    • 项目各工种是如何协作的
    • TBA课程学习
收藏
  • chrome控制台怎么复制对象
  • 小程序键盘弹起后顶起自定义导航问题
  • node子进程如何输出和关闭
  • 代理域名后webpack热更新失效及解决
  • 小程序scroll-view隐藏滚动条
  • npm包相关
  • electron下载慢解决
  • electron开发踩坑
  • mac升级后git找不到
  • electron打包找不到python
  • 安装imagemin-mozjpeg失败
  • 开发中的bug类型踩坑
  • 云端web项目开发踩坑
  • 如何快速定位bug
  • bug知多少
frost
2022-11-28

安装imagemin-mozjpeg失败

  1. 描述

    环境:

    macOS 12.6
    node v14.18.1
    
    1
    2
     yarn add imagemin-mozjpeg
    
    1

    遇到报错,如下

    [4/4] 🔨  Building fresh packages...
    error /Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/mozjpeg: Command failed.
    Exit code: 1
    Command: node lib/install.js
    Arguments:
    Directory: /Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/mozjpeg
    Output:
    connect ECONNREFUSED 0.0.0.0:443
    mozjpeg pre-build test failed
    compiling from source
    Error: Command failed: /bin/sh -c ./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8 libpng_LIBS='/usr/local/lib/libpng16.a -lz' --enable-static --prefix="/Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/mozjpeg/vendor" --bindir="/Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/mozjpeg/vendor" --libdir="/Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/mozjpeg/vendor"
    configure: error: no nasm (Netwide Assembler) found
    (太长略过)
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    从报错信息来看是nasm缺失,怎么解决呢?还得去 issue 看,去这里 (opens new window)。

  2. 安装相应的包,就可以正常安装了。

    # for macOS
    brew install automake nasm zlib
    
    # for Ubuntu
    sudo apt-get install nasm zlib1g-dev
    
    1
    2
    3
    4
    5

    当然也有人这样安装也是可以的,不过我已经解决上述问题了,就没尝试,这里也贴出来,见issue (opens new window)。

    brew install automake autoconf libtool
    
    1

    后话:

安装 png 插件时遇到类似的问题

yarn add imagemin-pngquant
1

报错如下

error /Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/pngquant-bin: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/pngquant-bin
Output:
connect ECONNREFUSED 0.0.0.0:443
pngquant pre-build test failed
compiling from source
Error: pngquant failed to build, make sure that libpng is installed
    at /Users/macbookpro/Documents/app/test/demos/node-test/imagemin-demo/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Promise.all (index 0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14

解决方式也类似,安装就好了。

brew install libpng
1

在 windows 上安装,又出幺蛾子了,所幸有前辈趟坑了,见issue (opens new window)。安装 VC runtime 后 确实管用。

如果还是有问题,试试降低版本:

npm install imagemin-pngquant@5.0.1 --save
npm install pngquant-bin@4.0.0 --save

1
2
3
上次更新: 2023/01/29, 18:04:46
electron打包找不到python
开发中的bug类型踩坑

← electron打包找不到python 开发中的bug类型踩坑→

最近更新
01
提交代码时修改commit消息
04-09
02
如何快速定位bug
02-20
03
云端web项目开发踩坑
08-25
更多文章>
Theme by Vdoing | Copyright © 2021-2025 dwfrost | 粤ICP备2021118995号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×