npm ERR! command sh -c node-gyp rebuild,fatal error: ‘jpeglib.h‘ file not found npm ERR!

错误解决 同时被 2 个专栏收录
10 篇文章 0 订阅
1 篇文章 0 订阅

使用React脚手架创建React项目报错:

报错日志如下:

admindeiMac-3:react_redux albert$ create-react-app hello-react

Creating a new React app in /Users/albert/react_redux/hello-react.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code 1
npm ERR! path /Users/albert/react_redux/hello-react/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! SOLINK_MODULE(target) Release/canvas-postbuild.node
npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/Backend.o
npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
npm ERR!   CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
npm ERR! ../src/backend/Backend.cc:111:10: warning: address of stack memory associated with local variable 'msg' returned [-Wreturn-stack-address]
npm ERR!   return msg.c_str();
npm ERR!          ^~~
npm ERR! 1 warning generated.
npm ERR! In file included from ../src/backend/PdfBackend.cc:1:
npm ERR! In file included from ../src/backend/PdfBackend.h:4:
npm ERR! ../src/backend/../closure.h:6:10: fatal error: 'jpeglib.h' file not found
npm ERR! #include <jpeglib.h>
npm ERR!          ^~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/canvas/src/backend/PdfBackend.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/Users/albert/react_redux/hello-react/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 19.6.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/albert/react_redux/hello-react/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/albert/react_redux/hello-react/node_modules/canvas
npm ERR! gyp ERR! node -v v14.16.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/albert/.npm/_logs/2021-03-01T07_57_55_062Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... package.json
Deleting hello-react/ from /Users/albert/react_redux
Done.

解决方法:

brew install pkg-config cairo libpng jpeg giflib

 

  • 1
    点赞
  • 3
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 博客之星2020 设计师:CY__ 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值