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.

I tried it with quotes as you suggested – same result of
» Error: Not Found. Strange!

Hi @BlockchainAlchemist!

Can you give us the full output of the command?
I want to see what the error relates to.

Hey there! Could you please try the following and see if it helps?

# unlink the site from Netlify
netlify unlink

# relink the site to Netlify
netlify link

# link will give you options on how to find which Netlify site you're deploying

# try the deploy again
netlify deploy

For additional context, it looks like the CLI is failing to find a site ID (relevant source code), so what this does is reestablish a link to the site — which should (hopefully!) fix the deploys.

@jlengstorf @marcus Thanks. When I ran ‘netlify unlink’, the output was

Unlinked undefined from undefined

When I ran ‘netlify link’, I was able to link it to my recently updated Netlify site, helloworlddeploytest:

Directory Linked

Admin url: https://app.netlify.com/sites/helloworlddeploytest
Site url: https://helloworlddeploytest.netlify.com

Site id saved to C:\Users\matth\Repos\hello-world2.netlify\state.json

You can now run other netlify cli commands in this directory

When I ran ‘netlify deploy’ and ‘netlify deploy --prod’, the output froze in the same way as my initial post:

C:\Users\matth\Repos\hello-world2>netlify deploy --prod
Deploy path: C:\Users\matth\Repos\hello-world2.netlify\build
Deploying to live site URL…
√ Finished hashing 0 files
√ CDN requesting 0 files
√ Finished uploading 0 assets

  • Waiting for deploy to go live… » Warning:
    » {
    » “name”: “TimeoutError”
    » }
    »
    \ Waiting for deploy to go live…TimeoutError: Promise timed out after 1200000 milliseconds
    at Timeout._onTimeout (C:/Users/matth/AppData/Roaming/npm/node_modules/netlify-cli/node_modules/p-timeout/index.js:27:54)

Hey there! It looks like the deploy path is defaulting to .netlify/build, and that’s resulting in an empty deploy.

That it hangs is a bug, but fortunately there’s a fix: specify the directory with the -d flag:


netlify deploy -d . --prod

this will deploy the current directory — you can swap in -d build or whatever the folder is that you want to deploy.

Let me know if that solves this for you!

1 Like

@jlengstorf That worked! I had to specify the public directory to get the site working:
netlify deploy -d public --prod

Is there a way to change the default deploy path, which would save a little time? (I wonder how the default path was re-routed in the first place).

Thanks again.

I think you can specify it in netlify.toml:

[build]
  publish = public
1 Like