Deploy with Gatsby Is Hanging

This is a Gatsby site. I configured Netlify to point to my public directory where the production files are located (‘netlify deploy --dir=public’). When I type ‘netlify deploy --prod’, the command keeps hanging on “Waiting for deploy to go live…” and then times out. Snapshot below. How to fix this? Thank you in advance.

image

Hi, @BlockchainAlchemist. We’d also like to understand why this is occurring and help to get it working.

Is this a large site? How many files are in the public directory being deployed?

Is this a public repo? If so, would you be willing to send us a link to it?

If this is a private repo, are there know reproduction steps which trigger this issue? And, if so, what are the reproduction steps?

Finally, if the issue can be reproduced, is there an example repo which can be shared with us?

Hi @luke, thank you for your reply. This is Gatsby’s basic Hello World site that has only four files in the public directory (I originally followed these instructions to create it). It is a private repo in which the problem was reproduced with the ‘netlify deploy --prod’ command.

For testing, I created a public repo and uploaded the files, saved at https://github.com/BTCAlchemist/hello-world-gatsby-test. For some reason, I was not able to upload the folders node_modules, .cache, and .netlify. Why is that? I am new to this and appreciate your further guidance.

Hi there,

the beauty of package management (by tools such as yarn, npm, etc) is that you don’t need to upload the node_modules folder - in fact, you shouldn’t! It’s often very large and unwieldy. I’m not 100% sure this is true, but it is very likely we explicitly prohibit you from uploading those files.

Instead, the package.json file contains information about which packages your project requires.

Our service is configured to look at your project, specifically, your package.json file, read it, understand which packages it needs, then trigger a download to fetch those packages and install them - our servers talk to the servers where the packages are hosted and coordinate that all on their own. That’s where the node_modules folder comes from - it is generated by npm and the package contents are stored there.

The .cache file contains information that is generated automatically - and @luke can verify this, but the .netlify file is also automatically generated, I believe.

In essence, in order to deploy a project that configures itself the most important file is the package.json.

you should prohibit the upload to github of those files (node_modules, and the .netlify and .cache) files with a .gitignore, ideally. I have a feeling it won’t hang any more. Keep us posted.

1 Like

@BlockchainAlchemist I also wanted to mention my recommendations for a Gatsby site using a Git repository.

If you want to use the Netlify CLI tool to publish the site, run gatsby build first to create the static files required and then upload only those files (normally the public directory). This might be done using this command:

netlify deploy --prod --dir=public

You can also link the Git repo to the direct to the Netlify site and you can use our continuous deployment method.

If you use the Git backed continuous deployment, the build command would be gatsby build and the publish directory would be public.

If this is done then when you run git push locally, Netlify will clone the updated repo, run the build command, and publish the results automatically (unless there are build errors or automatic publishing is disabled).

@perry, thank you for explaining that Netlify automatically installs needed packages per the package.json file.

@luke, thank you for your feedback. My test Github repo has successful continuous deployment at https://helloworldgithubtest.netlify.com/. However, I am unable to deploy this site from my local machine using the Windows 10 command prompt, which is my preferred method for speed.

As you suggested, I successfully ran gatsby build. Then I ran netlify deploy --prod --dir=public, but the result said, “» Error: Not Found”. I also tried netlify deploy --prod with the same error. (Netlify said an update is available, which I installed, but then had the same error result). Below is a snip of my public folder, which is the same in the above-linked repo. What to do?

looks like you’ve set “public” as your publish directory, but from your screenshot, that folder doesn’t exist. Could you run gatsby build locally to generate that folder and then run the deploy again? Let me know if that helps.

Hi @Dennis, thank you for your reply. The screenshot above was of my public folder, which already exists. Here is a screenshot of the root directory folder. I ran netlify deploy --prod from this root directory in the console (also just tested that command from the public folder). Any ideas about what might cause the » Error: Not Found issue?

Hmm, could you try putting quotes around your option like this: netlify deploy --prod --dir="public"? On unix operating systems like Linux and macOS, that’s not necessary but I’m not sure if it is for the Windows command prompt. Let me know if that helps.