Search code examples
zshoh-my-zshnyc

Yarn installed nyc successfully, but zsh says "command not found"


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


Solution

  • 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