0

After installing oh-my-zsh and reinstalling node and npm again, I install npm-check-updates globally and try to call 'ncu' (the npm-check-updates command). However, I get an error: zsh: command not found: ncu. Does anyone know how to fix this?

Vincent Chee
  • 15
  • 1
  • 7

4 Answers4

1

After an install you can run rehash so zsh will analyse what new executables are available on $PATH.

Not sure if that would fix the problem, I know it fixes the missing tab completion entry after install.

lolesque
  • 10,693
  • 5
  • 42
  • 42
1

I have corrected this problem with the following instructions:

sudo npm install -g npm-check-updates
Hermit-Z
  • 11
  • 2
0

Make sure the 'ncu' package can be found in the $PATH environment variable. Try this, to find where 'ncu' is supposed to be installed:

which ncu

If it still gives you trouble, try to see if it's in /usr/bin, $HOME/npm/bin, /usr/local/lib or /usr/sbin, and check that your $PATH environment variable contains a way to 'ncu'. Your $PATH environment variable, which can be found in

$HOME/.bashrc (Linux)
$HOME/.bash_profile (MacOS)

should look something like this:

export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/npm/bin
jasper
  • 123
  • 2
  • 10
  • Also try $HOME/npm/bin as something that $PATH should contain if it's a npm package!! – jasper Dec 25 '19 at 16:54
  • I don't think the original solution scales if I'm trying to add multiple packages. – Vincent Chee Jan 08 '20 at 20:47
  • By adding $HOME/npm/bin to path, it will include all packages installed from then on @VincentChee – jasper Jan 08 '20 at 20:48
  • I think it's `$HOME/.npm/bin`, but it possibly depends on the OS, I'm on OS X, that may be the solution for Windows? – Vincent Chee Jan 08 '20 at 20:58
  • It should be the solution for all Operating Systems. Just make sure you update .bash_profile with the correct location of the npm packages in the PATH variable. – jasper Jan 08 '20 at 21:18
0

FYI I am using a OSX.

The problem was that my export path in my .zshrc was wrong. This was what it was previously:

export PATH=$HOME/bin:/usr/local/bin:$PATH.

Notice there is nothing pointing at npm or any of the packages I installed globally. For anyone who has this problem in the future...

  1. Ensure that npm is installed and that you can still run npm commands (if not uninstall then install npm). Then run npm -g list --depth 0 to list all your global packages.
  2. Go into your home folder and press +Shift+. (shows all hidden files/folders), there should be a .npm folder there, ensure the packages in the list you obtained in the previous step matches what's in the bin folder.
  3. Edit your export PATH string accordingly:

export PATH=$HOME/bin:/usr/local/bin:**$HOME/.npm/bin**:$PATH.

This worked for me!

Vincent Chee
  • 15
  • 1
  • 7