In this tutorial, we are going to learn about how to fix the
Gatsby: command not found issue after installing the
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 found
This 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
npm config set /usr/local
- Now, install the gatsby-cli globally by using the following command.
npm install -g gatsby-cli
Note: If you are using mac then you need to add
sudobefore the above command.
- Verify the successful installation by running the
If it outputs the version number like this, then you are successfully installed.
Gatsby CLI version: 2.12.51
You can now create new gatsby projects like this.
gatsby new my-new-gatsby-blog