zsh

How to Fix zsh: command not found: sanity on Mac

Sanity is an open-source content management platform that makes it easy for you to create, manage and publish content on your website or app. It is built-in on top of GraphQL, a powerful API technology used for query and data manipulation tasks. Building complex applications becomes a lot easier once you manage to install in on your system. It provides a command-line interface called Sanity CLI that allows you to interact with Sanity platform.

For Mac users, it is indeed a great platform and most people used it seamlessly on their systems. However, some users may encounter “zsh: command not found: sanity” error in Zsh while running the sanity-related commands.

Read this guide thoroughly to find solutions to fix the “zsh: command not found: sanity” error in Zsh on Mac.

How to Fix “zsh: command not found: sanity” Error in Zsh on Mac

While using Zsh on Mac, you may encounter a similar error when you try to run sanity-related commands:

This type of error indicates that the application is not installed on your system or the path variable is not set correctly. The ideal way to fix the issue is to install Sanity CLI on your Mac system because in most cases, the problem will be fixed as the installation automatically set the PATH in Zsh.

How to Install Sanity CLI on Mac?

The ideal and effective way to install Sanity CLI on Mac is to use the services of Node Package Manager (NPM).

How to Install NPM on Mac?

You can install NPM on your Mac system by visiting the official website and downloading the .pkg file with a single click on the Apple icon.

Once the .pkg file is downloaded, you have to run this file and follow the onscreen installation to complete the NPM installation on Mac.

Go back to your terminal to ensure NPM is successfully installed on Mac by running the following command:

node -v

How to Install Sanity CLI from NPM on Mac?

You can now install Sanity CLI globally from NPM on Mac by running the following command:

npm install -g @sanity/cli

Once done, you can use the sanity-related command to ensure the error is fixed.

Here, I have used the version command to ensure Sanity CLI is installed on the system.

sanity --version

Alternatively, you can also use the following command to ensure it is there in the bin directory of your system.

which sanity

Conclusion

Getting the “zsh: command not found: sanity” error will hinder our progress in interacting with the Sanity platform from Zsh. However, with an easy fix which is installing Sanity CLI from NPM, you can seamlessly use sanity-related commands on your terminal. The above guide has provided the methods to install NPM on Mac, then install Sanity CLI through NPM to fix the “zsh: command not found: sanity” in Zsh on Mac.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.