How to fix the Gatsby command not found issue
In this tutorial, we are going to learn about how to fix the Gatsby: command not found issue after installing the gatsby-cli.
When we install a gatsby-cli using the npm i -g gatsby-cli command and trying to use a gatsby command sometimes we will see the following issue in our terminal.
-bash: gatsby: command not foundThis issue occurs due to the mismatch of the npm config prefix option.
To fix this issue follow the below steps:
- First, delete the npm path prefix by running the following command.
npm config delete prefix- Set a path prefix to
/usr/local.
npm config set /usr/local- Now, install the gatsby-cli globally by using the following command.
npm install -g gatsby-cliNote: If you are using mac then you need to add
sudobefore the above command.
- Verify the successful installation by running the
gatsby -vcommand.
gatsby -vIf it outputs the version number like this, then you are successfully installed.
Gatsby CLI version: 2.12.51You can now create new gatsby projects like this.
gatsby new my-new-gatsby-blog

