0

I am having a problem running Sanity's CLI. I have installed the CLI with npm install -g @sanity/cli which works without a problem, and everything is installed correctly (as far as I can tell).

However, trying to use any of their CLI instructions, such as sanity init, I get this error message:

zsh: command not found: sanity

I am using npm version 6.14.11 and node version v14.16.0.

I've also been noticing a few random commands return the same zsh: command not found for various packages.

Davis Kane
  • 1
  • 1
  • 1
  • When you run `sanity --version` what happens? I would probably suggest `npm uninstall -g @sanity/cli` then running `npm install -g @sanity/cli` again. Once you've done that, check your global install with `npm -g ls @sanity/cli` – Oliver Heward Mar 19 '21 at 09:06
  • Running `sanity --version` returns the same `zsh: command not found: sanity` error. Tried uninstalling and reinstalling and am getting the same issue. When I reinstalled it, I did get the version: @sanity/cli@2.6.0 – Davis Kane Mar 21 '21 at 16:05
  • 1
    @DavisKane : Provide the complete PATH to `sanity`. Alternatively, make sure that the directory containing the _sanity_ executable is in your `PATH`. – user1934428 Mar 22 '21 at 11:27
  • @DavisKane : See [here](https://www.wikihow.com/Check-Path-in-Unix) for a detailed treatment of your problem. – user1934428 Mar 22 '21 at 11:29

4 Answers4

0

@user1934428 is right.

I just change in the command "sanity ..." to "usr/local/Cellar/node/16.3.0/lib/node_modules/@sanity/cli/bin/sanity ..." and it worked

0

I had a similar problem on my mac which was caused by not installing sanity globally.

Go to your terminal and enter:

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

Enter your password then install sanity globally

npm install -g ng

This should solve the issue and sanity commands should work too.

Sam Wong
  • 23
  • 4
0

Use npx instead of directly typing sanity manage

after so many trials it worked for me

npx sanity manage
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
sr1r4m
  • 1
-1

with npx it works

npx @sanity/cli init
Kabir
  • 1
  • 1