React 创建项目报错

npm ERR! code 1
npm ERR! path /Users/tangwenjing/Html/imooc/my-app1/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! /bin/sh: pkg-config: command not found
npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 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/tangwenjing/Html/imooc/my-app1/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.4.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/tangwenjing/Html/imooc/my-app1/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/tangwenjing/Html/imooc/my-app1/node_modules/canvas
npm ERR! gyp ERR! node -v v14.17.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/tangwenjing/.npm/_logs/2021-06-03T09_55_42_223Z-debug.log

解决方案:直接安装 nodejs 安装包,因该是因为 npm 版本的问题

上一篇:Nodejs插件引入第三方动/静态链接库(Libtorch)的踩坑记录


下一篇:解决 node-gyp 错误问题|node与python版本不匹配报错|node-gyp|vue