执行npm install失败,提示prebuilds.tgz文件不存在求助
npm install 失败:prebuilds.tgz 文件不存在错误
执行npm install时遭遇报错,具体错误信息如下:
npm ERR! code 1 npm ERR! path /Users/alex/Documents/serviceName/node_modules/platform-tracer/node_modules/ls-trace npm ERR! command failed npm ERR! command sh -c node scripts/post_install.js npm ERR! Extracting prebuilt binaries. npm ERR! Extraction of prebuilt binaries failed. npm ERR! node:internal/process/promises:289 npm ERR! triggerUncaughtException(err, true /* fromPromise */); npm ERR! ^ npm ERR! npm ERR! [Error: ENOENT: no such file or directory, stat 'prebuilds.tgz'] { npm ERR! errno: -2, npm ERR! code: 'ENOENT', npm ERR! syscall: 'stat', npm ERR! path: 'prebuilds.tgz' npm ERR! } npm ERR! npm ERR! Node.js v19.0.1 npm ERR! A complete log of this run can be found in: npm ERR! /Users/alex/.npm/_logs/2022-11-16T02_01_25_429Z-debug-0.log
已尝试操作:
- 卸载重装 Node.js 和 npm
- 执行
npm cache verify - 更换 Node.js 旧版本(当前版本为19.0.1,npm版本9.1.1)
问题仍未解决,需完成 npm 包安装。
解决方案尝试
1. 清理依赖文件后重装
- 删除项目根目录下的
node_modules文件夹 - 删除
package-lock.json文件 - 重新执行
npm install
2. 强制从源码构建 ls-trace
针对报错的ls-trace包,跳过预构建二进制包,强制从源码编译:
npm install --build-from-source=ls-trace
或通过环境变量全局启用源码构建:
npm_config_build_from_source=true npm install
3. 锁定兼容的 ls-trace 版本
检查ls-trace版本与当前 Node.js 的兼容性,在package.json中指定一个稳定兼容版本(示例):
"dependencies": { "ls-trace": "1.12.0" }
保存后重新执行npm install
4. 临时跳过 post-install 脚本
若上述方法无效,可临时跳过包的 post-install 脚本(注意:可能导致部分功能缺失):
npm install --ignore-scripts
5. 手动补充缺失的预构建包
报错核心是找不到prebuilds.tgz,可手动下载补充:
- 从
ls-trace的官方仓库或 npm 页面找到对应系统的预构建包下载地址 - 下载
prebuilds.tgz文件 - 将文件放到
/Users/alex/Documents/serviceName/node_modules/platform-tracer/node_modules/ls-trace目录下 - 重新执行
npm install
内容的提问来源于stack exchange,提问作者Mohammad Arshad
相关产品推荐
相关产品推荐

