未找到浪涌命令

Surge Command Not Found

我已经阅读了很多关于终端中 command not found 错误消息的帖子,但我找不到任何特定于 surge.

的帖子

我在终端中使用 surge 命令时 运行 遇到错误。我 运行 npm install --global surge 在我的终端中,一切看起来都很好,但是当我 运行 命令 surge 它 returns command not found.

我电脑上的其他 npm 包工作正常。我测试了 create-react-app 并且没有错误。我对此有些陌生,任何建议将不胜感激!!

感谢和欢呼!!

您确定安装了surge可执行文件吗?

你在哪个 shell?

如果在 bash 中,尝试重新 hash-ing:

       hash [-lr] [-p filename] [-dt] [name]
              Each time hash is invoked, the full pathname of the command name is determined by searching the directories in $PATH  and  remembered.
              Any  previously-remembered  pathname is discarded.  If the -p option is supplied, no path search is performed, and filename is used as
              the full filename of the command.  The -r option causes the shell to forget all remembered locations.  The -d option causes the  shell
              to  forget  the  remembered  location of each name.  If the -t option is supplied, the full pathname to which each name corresponds is
              printed.  If multiple name arguments are supplied with -t, the name is printed before the hashed full pathname.  The -l option  causes
              output  to  be  displayed  in a format that may be reused as input.  If no arguments are given, or if only -l is supplied, information
              about remembered commands is printed.  The return status is true unless a name is not found or an invalid option is supplied.

您终端的当前 PATH 中可能缺少 surge 二进制文件。要检查是否是这种情况,请找到默认安装二进制文件的位置(在我的机器中是在 /usr/local/bin 目录下找到的)并检查该目录是否存在于您的 PATH 中,方法是 运行:

echo $PATH

如果没有,可以通过运行添加:

PATH=$PATH:/path/to/surge/location

然后检查它现在是否有效:

surge

如果是这样,要使此更改在重新启动后保持不变,您可以 echo 您定义的当前 PATH

echo $PATH

然后通过添加以下行将最后一条命令的结果导出到您的 ~/.bashrc 文件:

export PATH=/previous/command/output/here

用npx surge代替surge :)