当前位置: 首页 > 工具软件 > status-react > 使用案例 >

【React】mac下create-react-app出现错误的解决过程

杨星纬
2023-12-01

Author: jayzhen
Date: 2021.08.02

Package ‘harfbuzz’, required by ‘pango’, not found

  • npx create-react-app qadev-react-learn --use-npm
jayzhen:script apple$ npx create-react-app qadev-react-learn  --use-npm

Creating a new React app in /Users/apple/jayzhen/qadev/script/qadev-react-learn.

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/apple/jayzhen/qadev/script/qadev-react-learn/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! Package harfbuzz was not found in the pkg-config search path.
npm ERR! Perhaps you should add the directory containing `harfbuzz.pc'
npm ERR! to the PKG_CONFIG_PATH environment variable
npm ERR! Package 'harfbuzz', required by 'pango', not found
npm ERR! gyp: Call to 'pkg-config pangocairo --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (/Users/apple/jayzhen/qadev/script/qadev-react-learn/node_modules/node-gyp/lib/configure.js:351:16)
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:275:12)
npm ERR! gyp ERR! System Darwin 20.2.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/apple/jayzhen/qadev/script/qadev-react-learn/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/apple/jayzhen/qadev/script/qadev-react-learn/node_modules/canvas
npm ERR! gyp ERR! node -v v12.18.3
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/apple/.npm/_logs/2021-08-02T04_58_54_764Z-debug.log
  • brew install harfbuzz
Updating Homebrew...
Warning: harfbuzz 2.8.2 is already installed, it's just not linked.
To link this version, run:
  brew link harfbuzz
  • brew link harfbuzz
Linking /usr/local/Cellar/harfbuzz/2.8.2...
Error: Could not symlink lib/cmake/harfbuzz
/usr/local/lib/cmake is not writable.
  • sudo chown -R $(whoami) /usr/local/lib/cmake
  • 上面执行完后再执行: brew link harfbuzz 成功

其他需要安装的

brew install pixman
brew install cairo
brew install pango
brew install jpeg
brew install giflib
brew install libpng

可以通过 brew doctor 来检查 mac 的安装情况

参考资料

  1. https://stackoverflow.com/questions/27784545/brew-error-could-not-symlink-path-is-not-writable
 类似资料: