Package managers
Common commands
The following commands,
install, show, list
are common with package managers, such as npm
, brew
, or `pip.
Which version?
To know which of my package managers installed npm
, I can do the following
which npm
/home/linuxbrew/.linuxbrew/bin/npm
However, if I search for npm in the ubuntu package manager.
apt list|grep ^n
So it exists in apt too. How do I tell linux to use the version installed with apt?
echo $PATH|sed 's/:/\\n/g'
we find the following candidates:
/home/linuxbrew/.linuxbrew/bin
/home/linuxbrew/.linuxbrew/sbin
/home/linuxbrew/.linuxbrew/bin
/home/linuxbrew/.linuxbrew/sbin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
snap/bin
Let’s look in /usr/local/bin:
ls /usr/local/bin|grep ^n
n
node
npm
npx
Show the installed packages
/usr/local/bin/npm ls
Instead of the above, you can just do
which -a npm
/home/linuxbrew/.linuxbrew/bin/npm
/home/linuxbrew/.linuxbrew/bin/npm
/usr/local/bin/npm