[英]Ngrok with vagrant doesn't work in windows 10
我正在嘗試通過 ngrok 公開我的本地服務器。 我正在使用 vagrant 在我的本地服務器上運行我的項目,所以,我讀到有一個 vagrant 和 ngrok 插件,“vagrant share”。 我已經下載了 ngrok,但是當我運行命令 vagrant share 時,結果如下:
在 PATH 變量中找不到試圖運行的可執行文件 'ngrok' Vagrant。 運行 Vagrant 共享需要“ngrok”可執行文件。 如果“ngrok”當前安裝在非標准位置,請將該位置附加到 PATH 變量並再次運行此命令。
我已經將 ngrok 放在環境變量中,但它不起作用。
知道如何修復它嗎? 我有好幾天遇到這個問題,但無法解決。
您是否嘗試過手動安裝vagrant share
插件?
vagrant plugin install vagrant-share
您必須在 Windows PATH 中明確包含 ngrok。 我懷疑vagrant share
插件沒有安裝ngrok
。
為了為自己做同樣的事情,我碰巧在運行 Visual Studio Code,使用 PowerShell 作為終端。 我從 ngrok 網站下載了 zip 格式的 ngrok,將其解壓縮,放在我的 Windows 主目錄中,然后將其添加到 PowerShell 路徑中。 然后vagrant share
立即起作用(我不必明確設置 authtoken 或連接帳戶)。 下面用您的帳戶 ID 替換windowsuser
。
c:\\Users\\windowsuser
$env:Path += ";c:\\users\\windowsuser"
PS C:\Users\windowsuser\vagrant_getting_started> ngrok
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
DESCRIPTION:
ngrok exposes local networked services behinds NATs and firewalls to the
public internet over a secure tunnel. Share local websites, build/test
webhook consumers and self-host personal services.
Detailed help for each command is available with 'ngrok help <command>'.
Open http://localhost:4040 for ngrok's web interface to inspect traffic.
EXAMPLES:
ngrok http 80 # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080 # port 8080 available at baz.ngrok.io
ngrok http foo.dev:80 # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls -hostname=foo.com 443 # TLS traffic for foo.com to port 443
ngrok start foo bar baz # start tunnels from the configuration file
VERSION:
2.3.35
AUTHOR:
inconshreveable - <alan@ngrok.com>
COMMANDS:
authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command
PS C:\Users\windowsuser\vagrant_getting_started>
vagrant share
應該可以工作; 如您所見,我正在學習 vagrant 教程。PS C:\Users\windowsuser\vagrant_getting_started> vagrant share
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
default: Local HTTP port: 4567
default: Local HTTPS port: disabled
default: Port: 2200
default: Port: 4567
==> default: Creating Vagrant Share session...
==> default: HTTP URL: http://e058e1d1b464.ngrok.io
==> default:
C:\Users\windowsuser>set PATH=%PATH%;C:\Users\windowsuser
在您的 $PATH 中僅提供可以找到 ngrok 二進制可執行文件的路徑。 例如: /path/to
是正確的,而不是/path/to/ngrok
至少那是我一開始的錯誤。 希望這個細節對某人有幫助。 原則上@learning2learn 的答案是正確的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.