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

无法运行appium-doctor:MODULE_NOT_FOUND问题求助

解决M1 Monterey系统上appium-doctor启动失败的MODULE_NOT_FOUND问题

问题详情

我是Appium新手,在安装过程中遇到appium-doctor相关问题。执行npm install appium-doctor -g和npm fund时得到如下输出:

├── https://github.com/sponsors/isaacs
│   └── glob@7.2.3
├── https://github.com/sponsors/feross
│   └── safe-buffer@5.2.1, buffer@5.7.1, base64-js@1.5.1, ieee754@1.2.1
└── https://github.com/sponsors/epoberezkin
    └── ajv@6.12.6

执行appium-doctor命令时出现如下报错:

node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module './build/bin/appium-doctor'
Require stack:
- /opt/homebrew/lib/node_modules/appium-doctor/appium-doctor.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/appium-doctor/appium-doctor.js:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/opt/homebrew/lib/node_modules/appium-doctor/appium-doctor.js' ]
}

已尝试重新安装node和appium-doctor,但问题仍未解决。环境信息:M1 Monterey 12.5.1、Homebrew 3.6.1、node v16.17.0、npm 8.19.1。

解决方案

这个问题主要是M1架构下appium-doctor预编译二进制文件不兼容导致的,按以下步骤解决:

  • 彻底卸载并清理残留的appium-doctor

    npm uninstall -g appium-doctor
    rm -rf /opt/homebrew/lib/node_modules/appium-doctor
    
  • 用Rosetta 2启动终端(针对M1芯片)
    找到「终端.app」→右键选择「显示简介」→勾选「使用Rosetta打开」→关闭终端后重新打开

  • 强制从源码编译安装appium-doctor

    npm install -g appium-doctor --build-from-source
    
  • 验证安装
    执行appium-doctor,如果正常输出环境检查结果则问题解决。

备选方案(如果上述步骤无效)

  • 用nvm管理arm64架构的Node.js版本
    1. 安装nvm:brew install nvm,并按照提示配置环境变量到~/.zshrc或~/.bashrc
    2. 安装arm64版本的Node.js 16:nvm install 16 --arch=arm64
    3. 切换到该版本:nvm use 16
    4. 重新安装appium-doctor:npm install -g appium-doctor

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 16:35:23