Deployment strategy

Hi,

I am pretty new to Netlify. I have a project connected to a git repo where I have both my Strapi backend and my gatsby frontend.

I would like to try out netylify-cli. In the root of my project I have the folders backend and frontend. In the frontend I have a gatsby project. To use netlify-cli, and use GIT as my CI, I cd into my frontend folder and try:

  • netlify login
  • netlify init

When prompted I set a site name, and then I am prompted for a build command, so I run the:
gatsby build command
And when prompted Directory to deploy, I supply
public/

But the build fails as it complains on my gatsby build and I get the following error:

1:01:42 AM: ┌───────────────────────────────────┐
1:01:42 AM: │ 1. Build command from Netlify app │
1:01:42 AM: └───────────────────────────────────┘
1:01:42 AM: ​
1:01:42 AM: $ gatsby build
1:01:42 AM: bash: gatsby: command not found
1:01:42 AM: ​
1:01:42 AM: ┌─────────────────────────────┐
1:01:42 AM: │ “build.command” failed │
1:01:42 AM: └─────────────────────────────┘
1:01:42 AM: ​
1:01:42 AM: Error message
1:01:42 AM: Command failed with exit code 127: gatsby build
1:01:42 AM: ​
1:01:42 AM: Error location
1:01:42 AM: In Build command from Netlify app:
1:01:42 AM: gatsby build
1:01:42 AM: ​
1:01:42 AM: Resolved config
1:01:42 AM: build:
1:01:42 AM: command: gatsby build
1:01:42 AM: commandOrigin: ui
1:01:42 AM: publish: /opt/build/repo/public

I tried to follow the instructions on the gatsby docs
I tried also the instructions on this netlify docs page to do it via the netlify gui, but getting the same error for the gatsby build command failing.

What am I missing or done incorrectly?

Thanks :slight_smile:

Hiya @lupis and welcome to our community! Few questions that I think will help you get things sorted:

  1. do you need to build from WITHIN your frontend directory? If so, and if no files are needed from outside id, you could set a base of that frontend folder to start the build there, and look for config files such as yarn.lock there.
  2. regardless of where you build, we only install dependencies in case you have a yarn.lock
    or package.json in place specifying them - so I think you’re missing gatsby in whatever we are finding (which may be nothing). Could you elaborate on your package manager config so we can try to understand it?

I solved it, my mistake was that I set the path wrong, the public directory was set up in a wrong way from my side.

-thanks