1. 程式人生 > 其它 >mockm remote 不能正常使用的解決方案

mockm remote 不能正常使用的解決方案

原因是由於 ngrok 強制要求更新到最新版本。

mockm v1.1.25-alpha.15 之前的版本可以在 mockm 的安裝目錄使用 npx ngrok update 更新版本來解決此問題。

以下是參考命令:

# 獲取全域性安裝目錄(假設你是全域性安裝的 mockm, 如果是區域性安裝的可以跳過此步)
> npm root -g
node_modules

# 進入 mockm 的所在目錄
> cd node_modules/mockm

# 更新 ngrok
> npx ngrok update

詳細原因分析

錯誤現象:

# 開啟 remote 模式時一直輸出以下資訊, 遠端服務資訊為空
> mm remote err connect ECONNREFUSED 127.0.0.1:58725 err connect ECONNREFUSED 127.0.0.1:58726 err connect ECONNREFUSED 127.0.0.1:58727 err connect ECONNREFUSED 127.0.0.1:58725 遠端服務資訊: port: replayPort: testPort: # 檢視本地 ngrok 版本 > ngrok -v ngrok version 2.3.35 # 直接使用 ngrok 來啟動外網服務, 得到具體的原因是未註冊的使用者必須保持更新 ngrok
> ngrok http 80 Your ngrok agent version "2.3.40" is no longer supported. Only the most recent version of the ngrok agent is supported without an account. Update to a newer version with `ngrok update` or by downloading from https://ngrok.com/download. Sign up for an account to avoid forced version upgrades: https://ngrok.com/signup. ERR_NGROK_120