1

I have read through a lot of posts regarding command not found error messages in the terminal but I can't find any specific to surge.

I am running into an error when using the surge command in my terminal. I ran npm install --global surge in my terminal and everything looks okay, but when I run the command surge it returns command not found.

The other npm packages on my computer work fine. I tested create-react-app and no errors. I am somewhat new to this, any advice would be appreciated!!

Thanks and cheers!!

mtnezm
  • 1,009
  • 1
  • 7
  • 19

3 Answers3

9

Just use npx surge instead of surge :)

0

Are you sure surge executable is installed?

what shell are you in?

If in bash, try re-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.

vgersh99
  • 877
  • 1
  • 5
  • 9
  • Thanks for the reply! I am sorry for sounding like such a novice, but can you elaborate on your first question. To install I followed the instructions surge.sh, but I did receive this warning when installing - [npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142] –  Jun 11 '20 at 17:00
-1

There is a chance that the surge binary is missing from your terminal's current PATH. To check if that is the case, locate where is the binary installed by default (in my machine is found under /usr/local/bin directory) and check if that directory is present in your PATH, by running:

echo $PATH

In case it is not, you can add it by running:

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

Then check if it works now:

surge

If that's the case, to make this change persitent across reboots, you can echo the current PATH you have defined:

echo $PATH

And then export the result of that last command to your ~/.bashrc file, by adding this line:

export PATH=/previous/command/output/here
mtnezm
  • 1,009
  • 1
  • 7
  • 19