gyp: binding.gyp not found
环境
- win11(MacOS 虚拟机)
- node v20.11.1(fnm)
- pnpm
问题描述
前端工程安装 NPM 依赖时报错 gyp: binding.gyp not found
。
解决方式
找到上图报错信息中的 cwd 后面的路径,我这里是:
C:\Users\guangzanwang\code\puppet-xp-getting-started\node_modules\.pnpm\frida@15.2.2\node_modules\frida
在这个路径下创建文件 binding.gyp,并写入以下内容(sources 改成你的 NodeJS 路径):
{
"targets": [{
"target_name": "binding",
"sources": [ "C:/Users/guangzanwang/AppData/Roaming/fnm/node-versions/v20.11.1/installation" ]
}]
}
在这个目录下运行命令:
node-gyp rebuild
输出信息结尾出现这个说明构建通过了:
参考资料
- https://github.com/nodejs/node-gyp/issues/1709#issuecomment-604116882