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

使用Browserify+Babel打包JS时遇async_hooks找不到错误求助

解决Browserify+Babel打包时async_hooks找不到的问题

问题重现

执行Browserify打包命令时遭遇依赖解析错误:

browserify ./src/background.js > ./dist/bundle.js -t babelify

报错信息:

Error: Can't walk dependency graph: ENOENT: no such file or directory, lstat 'D:\prog\html\extvone\async_hooks' required by D:\prog\html\extvone\node_modules\on-finished\index.js

查看依赖包on-finished/index.js,发现其中有require('async_hooks')语句,但本地找不到对应模块文件。

相关环境与代码信息

  • 项目入口文件background.js开头代码:
import PythonShell from 'python-shell'; const express = require('express'); const app = express();
  • package.json中包含express@4.18.2依赖
  • Node.js版本为18.12.1 LTS
  • 移除express依赖后,打包可正常完成

已尝试的无效操作

  • 执行npm i重装所有依赖
  • 全局更新npm版本
  • 手动安装async_hooks包

最终解决办法

移除express这类Node.js专属的后端模块依赖,同时替换打包工具为VITE,替代原有的Browserify+Babel组合,后续打包流程恢复正常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 15:20:33