npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

[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
~ $


Platform Info

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

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
$ 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

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 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

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

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 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

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.