[英]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.