You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行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,可手动下载补充:

  1. 从ls-trace的官方仓库或 npm 页面找到对应系统的预构建包下载地址
  2. 下载prebuilds.tgz文件
  3. 将文件放到/Users/alex/Documents/serviceName/node_modules/platform-tracer/node_modules/ls-trace目录下
  4. 重新执行npm install

内容的提问来源于stack exchange,提问作者Mohammad Arshad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 19:11:31