[macOS Catalina 1.15.0 ] Appium through command line not available after downgrading

What I Wanted to Do

After downgrading Appium packages through npm, I lost appium
even though the environment variable is available in my .bash_profile

What Happened Instead

When I run

~ which appium ~ appium -v
-sh: appium: command not found
~ node -v v12.11.1 ~ npm -v
6.11.3
~ $

Details

Platform Info

  • Appium version (or git revision) that exhibits the issue: 1.9.1
  • Last Appium version that did not exhibit the issue (if applicable): 1.14.1
  • Desktop OS/version used to run Appium: macOS Catalina 10.15
  • Node.js version (unless using Appium.app|exe):
  • Mobile platform/version under test: iOS 12.1
  • Real device or emulator/simulator: iPhone 6
  • Appium CLI or Appium.app|exe: CLI

npm --versions npm -v 6.11.3 node -p process.platform
Darwin

Some background first.

Commands associated with global installs are linked into the bin folder under the โ€œprefixโ€ destination. For example, my global installs go to /usr/local, so the packages go into /usr/local/lib/node_modules and the commands are linked into /usr/local/bin:

$ npm prefix -g
/usr/local
$ npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@6.0.1
updated 1 package in 1.203s

The commands are found because the bin folder is listed in $PATH, see mine contains /usr/local/bin:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Now for your problem. If you check with the above commands, I expect the bin folder for your global prefix is not listed in your โ€œPATHโ€?

(It looks like you installed node using HomeBrew? I am not sure of the usual practice for HomeBrew installations and managing node and npm, but will confirm my assumptions so far before suggesting anything else!)

Yes, npm was likely set up with brew.
But npm packages are available in /usr/local/Cellar and also
in /usr/local/bin. I attached a gist to my comment

Below my .bash_profile before alteration :
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export ANDROID_HOME=/Users/{UserName}/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export NODE_HOME=/usr/local/bin/node
export M2_HOME=/Applications/apache-maven-3.5.2
export PATH=$PATH:$M2_HOME/bin
export PATH="/usr/local/sbin:$PATH"
export XCODE_HOME=/usr/local/bin
export PATH=$XCODE_HOME/appium:$PATH
homebrew=/usr/local/bin:/usr/local/sbin

And below my console output :
Last login: Mon Oct 7 10:37:51 on ttys001
~ npm prefix -g /usr/local/Cellar/node/9.3.0_1 ~ npm install -g n
/usr/local/Cellar/node/9.3.0_1/bin/n -> /usr/local/Cellar/node/9.3.0_1/lib/node_modules/n/bin/n

  • n@6.0.1
    added 1 package from 4 contributors in 0.246s
    ~ $

I removed also npm and node. I let you check my terminal output.
So my question is how to set npm prefix and install npm and node without brew ?
Thank you for your attention in this matter.

Should I download node from their website or what is the proper way to install npm on Mac ?

node and npm can work with HomeBrew, but lets leave that out of the picture for now.

I see you installed n. Here are two simple options, pick one. In both cases npm gets installed along with node.

Either option 1: install node from https://nodejs.org/ using the Mac installer

Or option 2:

n latest

First command to try after installing is

npm prefix -g

If things are working as expected then you should see:

$ npm prefix -g
/usr/local

If you do not see that then there is some more debugging to do.

Thank you. I appreciate it. I can keep on working with Appium.

1 Like