1

After what seems like a successful global installation of the NestJS CLI by running npm i -g @nestjs/cli, I am unable to get zsh to recognize the nest command. It always throws zsh: command not found: nest. I am working on a Macbook Pro with Big Sur v 11.6 and node v14.17.6. Any ideas at all as to why I am unable to get the command working would be very much appreciated.

4
  • Have you tried restarting your terminal? What's your `$PATH`` variable? Does it include the install location for npm global packages? Commented Sep 26, 2021 at 17:36
  • I have made sure to restart my terminal. When I run echo PATH this is what is spit out: /usr/local/opt/[email protected]/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin Commented Sep 26, 2021 at 17:43
  • 1
    Looks like globally installed npm packages aren't in your path. You can read through this SO post and answer for more info on the install path and how you can get it into your $PATH variable Commented Sep 26, 2021 at 17:53
  • Running npm root -g gives me /Users/daviddelgadillo/.npm-global/lib/node_modules. Is this what I need to add to my $PATH? Commented Sep 26, 2021 at 18:06

1 Answer 1

1

I fixed it the following way:

  1. I entered npm list -g in my terminal to check where global packages are installed.
    In my case it was /Users/aleksey.malakhov/.npm-global/lib.
  2. .npm-global contains bin and lib folders.
    We need /Users/aleksey.malakhov/.npm-global/bin to be exposed to zsh.
  3. I added path+=/Users/aleksey.malakhov/.npm-global/bin in my .zshrc file, restarted terminal checked nest -v and it worked.
    This topic helped me
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.