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

Dear 丶 2022-11-04 05:22 124阅读 0赞

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

报错日志如下:

  1. admindeiMac-3:react_redux albert$ create-react-app hello-react
  2. Creating a new React app in /Users/albert/react_redux/hello-react.
  3. Installing packages. This might take a couple of minutes.
  4. Installing react, react-dom, and react-scripts with cra-template...
  5. npm ERR! code 1
  6. npm ERR! path /Users/albert/react_redux/hello-react/node_modules/canvas
  7. npm ERR! command failed
  8. npm ERR! command sh -c node-gyp rebuild
  9. npm ERR! SOLINK_MODULE(target) Release/canvas-postbuild.node
  10. npm ERR! CXX(target) Release/obj.target/canvas/src/backend/Backend.o
  11. npm ERR! CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
  12. npm ERR! CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
  13. npm ERR! ../src/backend/Backend.cc:111:10: warning: address of stack memory associated with local variable 'msg' returned [-Wreturn-stack-address]
  14. npm ERR! return msg.c_str();
  15. npm ERR! ^~~
  16. npm ERR! 1 warning generated.
  17. npm ERR! In file included from ../src/backend/PdfBackend.cc:1:
  18. npm ERR! In file included from ../src/backend/PdfBackend.h:4:
  19. npm ERR! ../src/backend/../closure.h:6:10: fatal error: 'jpeglib.h' file not found
  20. npm ERR! #include <jpeglib.h>
  21. npm ERR! ^~~~~~~~~~~
  22. npm ERR! 1 error generated.
  23. npm ERR! make: *** [Release/obj.target/canvas/src/backend/PdfBackend.o] Error 1
  24. npm ERR! gyp ERR! build error
  25. npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
  26. npm ERR! gyp ERR! stack at ChildProcess.onExit (/Users/albert/react_redux/hello-react/node_modules/node-gyp/lib/build.js:194:23)
  27. npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:315:20)
  28. npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
  29. npm ERR! gyp ERR! System Darwin 19.6.0
  30. npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/albert/react_redux/hello-react/node_modules/.bin/node-gyp" "rebuild"
  31. npm ERR! gyp ERR! cwd /Users/albert/react_redux/hello-react/node_modules/canvas
  32. npm ERR! gyp ERR! node -v v14.16.0
  33. npm ERR! gyp ERR! node-gyp -v v7.1.2
  34. npm ERR! gyp ERR! not ok
  35. npm ERR! A complete log of this run can be found in:
  36. npm ERR! /Users/albert/.npm/_logs/2021-03-01T07_57_55_062Z-debug.log
  37. Aborting installation.
  38. npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
  39. Deleting generated file... package.json
  40. Deleting hello-react/ from /Users/albert/react_redux
  41. Done.

解决方法:

  1. brew install pkg-config cairo libpng jpeg giflib

发表评论

表情:
评论列表 (有 0 条评论,124人围观)

还没有评论,来说两句吧...

相关阅读