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

Deployment fails with: Deploy directory 'out' does not exist - when trying to deploy "serverless" #211

Closed
madze opened this issue Apr 10, 2021 · 4 comments
Labels
priority: low type: bug code to address defects in shipped code

Comments

@madze
Copy link

madze commented Apr 10, 2021

Describe the bug
Attempting to use the new one-click install Next.js feature (though this actually happens even if I install the plugin directly both via netlify.toml as well as in the UI).

I receive an error during deployment:

Deploy did not succeed: Deploy directory 'out' does not exist

However, I do have target set to "serverless" in the next.config.js and do not want to use next export because I have an api route that should use the netlify serverless functions.

To Reproduce
Steps to reproduce the behavior:

  1. Create a next.js project on github
  2. Setup CD with netlify
  3. Initiate a deployment

Expected behavior
The site to deploy using serverless functions for SSR and the next API route.

Versions

  • Next.js: 10.1.3

Additional notes:
The only solution I've been able to find when searching this error is to use next export to deploy a static site but then of course our api routes don't work.

It seems that perhaps the site just isn't being built as "serverless" for some reason...?

Here's the next.config.js:

module.exports = {
	target: 'serverless'
}

Or perhaps I need to setup my netlify account differently somehow?

Any help would be greatly appreciated!

Thanks!

@madze
Copy link
Author

madze commented Apr 10, 2021

UPDATE:

If I create a netlify.toml and add the following to it:

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

[build]
  command = "yarn build"
  publish = "out"

I seem to be finally getting the netlify-plugin-nextjs to run but then I get the following error:

Error: 'out/index.html' already exists

NOTE: This installs @netlify/plugin-nextjs@3.0.3

Build script in package.json:

"scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
  },

@lindsaylevine
Copy link

@madze hey! unfortunately i'll need:

  1. link to your build/deploy logs (i.e. https://app.netlify.com/sites/{sitename}/deploys/{deployid})
  2. a link to a simple repo that reproduces your issue

with an error like that, i can almost guarantee it's unique to your setup so those things will help a lot! and with that error in particular, it seems like perhaps you have your own index.html in your publish directory already?

@lindsaylevine lindsaylevine added type: bug code to address defects in shipped code priority: low labels Apr 11, 2021
@madze
Copy link
Author

madze commented Apr 11, 2021

@lindsaylevine - Thanks for the reply!

For some reason when the error occurred I was fixated on the "out" directory part of it (I think because of the first issue I was coming up against), but after reading your note about an existing html.file I realized that I had migrated this project over from a gatsby.js project and reused the existing public directory and of course the culprit was right there - I had just missed it when I gutted that directory of extraneous files.

I figured it had to probably be something silly that I was missing, especially because of the lack of results when I searched that error on the web.

At any rate, if anyone else happens upon a similar corner case as this, maybe this will help them as well.

Also btw, after deleting that file I was able to remove the@netlify/plugin-nextjs and build commands from the netlify.toml and the one click deployment worked like a charm!

Thanks a bunch! I'll go ahead and close this ticket.

@madze madze closed this as completed Apr 11, 2021
@lindsaylevine
Copy link

@madze of course always happy to help!! thanks for letting me/everyone know what you discovered! ❤️

serhalp pushed a commit that referenced this issue Apr 5, 2024

Verified

This commit was signed with the committer’s verified signature.
pt2121 Prat
* copying over mtime changes

* initial test changes

* update fetch-handler test

* added utime func

* update fetch-handler test

* test change

* adding utime for local testing

* small test update

---------

Co-authored-by: Rob Stanford <me@robstanford.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants