Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netlify Deploy workflow fails #148

Closed
Garfounkel opened this issue Dec 25, 2021 · 9 comments
Closed

Netlify Deploy workflow fails #148

Garfounkel opened this issue Dec 25, 2021 · 9 comments

Comments

@Garfounkel
Copy link

Garfounkel commented Dec 25, 2021

Trying to deploy through Netflify using the deploy button from the readme (Deploy to Netlify) fails saying the directory "out_publish" wasn't found.

I also tried deploying this repo myself, from a fresh clone I ran the following commands:

git clone https://github.com/styxlab/next-cms-ghost.git
cd next-cms-ghost
yarn

# Development
yarn dev

# Production
yarn build

# Deploy
netlify deploy --prod

Which resulted in the same error.

@Garfounkel
Copy link
Author

Garfounkel commented Dec 25, 2021

After a bunch of trial and error, I finally figured out how to deploy this repo to Netlify from a fresh clone.

git clone https://github.com/styxlab/next-cms-ghost.git
cd next-cms-ghost
yarn

# Development
yarn dev

# Export a static site to /out directory
yarn export

# Rename the output folder, or change the config file at netlify.toml accordingly
mv out out_publish

# Deploy
netlify deploy --prod

I'm sure those steps are very basic, but for me having absolutely no experience with yarn/nextjs/netlify it wasn't all that easy to figure out. May I suggest adding the full workflow to the readme?

Side note: this is just a solution for deploying from a local install but the Netlify one-click button from the readme is still failing with the same error.

@toreylittlefield
Copy link

@Garfounkel Thanks for the heads up because my deploy was failing as well. Did you update the netlify.toml to build = "yarn export" and publish = "out" ? I tried deploying to netlify but it's erroring out. Might try removing the next-plugin but I am unsure how that'll affect the app.

image

@Garfounkel
Copy link
Author

Did you update the netlify.toml to build = "yarn export" and publish = "out" ?

I haven't try deploying solely from Netlify's UI, but I think what you suggested should work. I would check if you can't specify somewhere in the Netlify UI that the build command is yarn export.

I also suggest trying to deploy manually if you haven't already:

git clone https://github.com/styxlab/next-cms-ghost.git
cd next-cms-ghost
yarn

# Development
yarn dev

# Export a static site to /out directory
yarn export

# Rename the output folder, or change the config file at netlify.toml accordingly
mv out out_publish

# Deploy
netlify deploy --prod

@toreylittlefield
Copy link

toreylittlefield commented Jan 5, 2022

@Garfounkel Thanks for the response. The manual deployment worked fine when I did it previously. In the Netlify UI you certainly can set the build commands but the netlify.toml will/should take priority and override anything set in the UI.
I updated my as such but yeah running into that Deploy failed due to an error in @netlify/plugin-nextjs plugin. error. :

[build]
  command = "yarn export"
  functions = "out_functions"
  publish = "out"

[build.environment]
  JAMIFY_NEXT_ISR = "false"
  JAMIFY_NEXT_FEATURE_IMAGES = "false"
  JAMIFY_NEXT_INLINE_IMAGES = "false"

[[plugins]]
  package = "@netlify/plugin-nextjs"

[[plugins]]
  package = "netlify-plugin-cache-nextjs"

When I try to deploy without the plugins I get a different type error:

9:20:36 AM: > Build error occurred
9:20:36 AM: TypeError [ERR_INVALID_ARG_TYPE]: The "filename" argument must be of type string or an instance of URL. Received an instance of URL

I'll see if I can solve it.

@toreylittlefield
Copy link

Just updating again that I've tried other configurations in the build process for netlify and removing the plugins for next but still always getting a build error. I am about to give up on this.

@styxlab
Copy link
Owner

styxlab commented Jan 5, 2022

Thanks for following up on this issue. I will have a look myself when I return from vacations.

Netlify changed and updated a bunch of things for Next.js deploys and this repo must be updated for that.

According to the Netlify docs, this repo needs at least 3 changes

  1. next.config.js: remove the line with target: 'serverless'

  2. Update plugin "@netlify/plugin-nextjs" to latest version

  3. netlify.toml: update build directory to

[build]
publish = ".next"

To get ISR and next/images working there are more changes needed, but those three might be sufficient to get the Netlify button working again.

@toreylittlefield
Copy link

Thanks for following up on this issue. I will have a look myself when I return from vacations.

Netlify changed and updated a bunch of things for Next.js deploys and this repo must be updated for that.

According to the Netlify docs, this repo needs at least 3 changes

  1. next.config.js: remove the line with target: 'serverless'

  2. Update plugin "@netlify/plugin-nextjs" to latest version

  3. netlify.toml: update build directory to

[build]
publish = ".next"

To get ISR and next/images working there are more changes needed, but those three might be sufficient to get the Netlify button working again.

Thanks for following up. Happy new year. I think I scoured the Netlify docs and already attempted these changes you mentioned but it did not build.

I believe it has to do with the next/images as you've said but I had a difficult time debugging that in the build log. I'll try your changes and report back my findings with the logs.

@styxlab
Copy link
Owner

styxlab commented Jan 9, 2022

PR #152 should fix the netlify deploy button. Things to note:

  • cache plugin is depreciated and now integrated into @netlify/plugin-nextjs
  • plugin @netlify/plugin-nextjs is autodetected and can be removed from the netlify.toml
  • I have also removed the function directory as functions should work out-of-the box now

Further work is needed on (1) next/images and (2) ISR. Both features are currently switched off on netlify builds. I will open new issues for both topics.

@toreylittlefield, @Garfounkel: Can you confirm that the netlify button is working for you as well?

@styxlab
Copy link
Owner

styxlab commented Jan 16, 2022

It fixed in my tests, so closing.

@styxlab styxlab closed this as completed Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants