7

Question: How do I make nyc visible to zsh?

Steps to recreate:

  1. I tried yarn add nyc -g (I was following steps that used npm so I just replaced npm i with yarn add)
  2. Then ran nyc report --reporter=html

zsh: command not found: nyc

  1. However, when I ran npx nyc --help, I got a full list of nyc functions!
  2. Then I tried yarn add -D (from the official nyc documentation)
  3. Then ran nyc report --reporter=text-lcov. Once again:

zsh: command not found: nyc

Marlo
  • 490
  • 3
  • 7
  • 21
  • 1
    What directory is `nyc` installed in? Is that directory on your path? – chepner Jan 28 '20 at 20:48
  • 1
    @chepner now that I've installed it globally, it's in `/usr/local/bin/nyc`, but I don't know where it was before. – Marlo Jan 28 '20 at 21:42

1 Answers1

13

Turns out I didn't install nyc globally. If that's the case for you, you can run nyc by appending npx before any nyc command (which is why npx nyc --help was working).

If you want to install nyc globally with yarn, you have to do: yarn global add nyc

Marlo
  • 490
  • 3
  • 7
  • 21