leoloso
November 14, 2024, 8:37am
1
Hi, my site is elaborate-cactus-b60dfa .
I’ve switched the repo to a monorepo. I’ve moved my application from the root folder to apps/gatographql
, including netlify.toml
. Following the Monorepo docs , I’ve updated the “packages directory” config in the Build settings, to point to apps/gatographql
.
I’ve successfully deployed the app to production (gatographql.com ). However, when I do netlify dev
in my laptop, I get the following error:
◈ Function ___netlify-server-handler has returned an error: ENOENT: no such file or directory, open '{...}/apps/gatographql/run-config.json'
I’ve also noticed the following:
It worked successfully deploying to Netlify, by using @netlify/plugin-nextjs@4.41.3
When using the latest version 5.8.1
, that same problem happened, and the deployment failed
So I guess there are actually 2 errors (when using a monorepo):
Why plugin-nextjs@4.41.3
fails with netlify dev
Why plugin-nextjs@5.8.1
fails deploying to prod
Please advice. Should I post this as a bug in github.com/opennextjs/opennextjs-netlify ? I’ve seen this other bug which may be related.
Thanks
leoloso
November 14, 2024, 9:52am
2
Update: I deleted the .netlify
folder from apps/gatographql
and now doing netlify dev
in my laptop works, using plugin-nextjs@4.41.3
. (I guess something was cached from a previous try using v5.8.1
).
So the problem happens only with plugin-nextjs@v5.8.1
, in all environments: netlify dev
and deploying to Netlify.
leoloso
November 14, 2024, 11:34am
3
Hmmmm there’s something else going on. I’ll close this issue, and open a new one.
leoloso
November 14, 2024, 12:21pm
4
Posted it as a bug in the repo:
opened 12:14PM - 14 Nov 24 UTC
Hi, I have a monorepo, with the website under `apps/gatographql`. I have the fol… lowing `netlify.toml`:
```toml
[build]
command = "npm run build --prefix apps/gatographql"
publish = ".next"
```
The base is empty, as I use a single `node_modules` for all apps.
For this website configuration, the package directory in the Build settings in Netlify has value `apps/gatographql`:

`apps/gatographql/package.json` has this content (notice there's a dependency to Next v14, for which the latest runtime, `plugin-nextjs@5.8.1`, is installed):
```json
{
"scripts": {
"build": "next build"
},
"dependencies": {
"next": "^14.1.3"
}
}
```
I want to deploy the website using the CLI. When I run this command:
```bash
netlify deploy --build --context deploy-preview
```
I get this error:
```
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Your publish directory was not found at: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next. Please check your build settings
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
Resolved config
build:
command: npm run build --prefix apps/gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next
publishOrigin: config
```
The error is because the `publish` directory is `/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next`, however it should be `/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/.next` (i.e., the `apps/gatographql/` bit is missing).
Indeed, the folder under `apps/gatographql/.next` was generated correctly during the build stage; then, during the deploy stage, it gets the path wrong.
I assume that's a bug.
I append the complete log at the bottom.
---
Btw, I have also tried with value `publish = "apps/gatographql/.next"` in `netlify.toml`.
In this case, I get a different error:
```
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Failed publishing static content
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onPostBuild" event in "@netlify/plugin-nextjs" from Netlify app
Resolved config
build:
base: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql
command: npm run build --prefix apps/gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/apps/gatographql/.next
publishOrigin: config
```
Notice that, in this case, the `publish` folder is now `/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/apps/gatographql/.next` (`apps/gatographql/` appears twice)
## Complete log
This is the complete response from running `netlify deploy --build --context deploy-preview`:
```
Netlify Build
────────────────────────────────────────────────────────────────
❯ Version
@netlify/build 29.36.3
❯ Flags
packagePath: apps/gatographql
❯ Current directory
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com
❯ Config file
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/netlify.toml
❯ Context
deploy-preview
❯ Using Next.js Runtime - v5.8.1
Cleaning up leftover files from previous builds
────────────────────────────────────────────────────────────────
(Pre cleanup completed in 13ms)
@netlify/plugin-nextjs (onPreBuild event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onPreBuild completed in 137ms)
build.command from netlify.toml
────────────────────────────────────────────────────────────────
$ npm run build --prefix apps/gatographql
> gatographql@0.1.0 build
> export $(cat .env | xargs) && NODE_OPTIONS=--max-old-space-size=8192 next build
▲ Next.js 14.1.3
- Environments: .env
Creating an optimized production build ...
Generated 379 documents in .contentlayer
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (230/230)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 31.9 kB 1.38 MB
├ ○ /_not-found 0 B 0 B
├ ○ /about 2.83 kB 124 kB
├ λ /api/deploy-algolia 0 B 0 B
├ ○ /architecture 174 B 84.8 kB
├ ● /architecture/[slug] 158 B 121 kB
├ ├ /architecture/cms-agnosticism
├ ├ /architecture/code-first
├ ├ /architecture/dataloading-engine
├ └ [+12 more paths]
├ ○ /blog 2.24 kB 1.31 MB
├ ● /blog/[slug] 1.52 kB 123 kB
├ ├ /blog/introducing-headless-wordpress-without-wordpress
├ ├ /blog/released-v70-to-power-standalone-plugins
├ ├ /blog/gatographql-gets-streamlined
├ └ [+46 more paths]
├ ○ /comparisons 4.6 kB 101 kB
├ ● /comparisons/[slug] 2.68 kB 124 kB
├ ├ /comparisons/gatographql-vs-wp-rest-api
├ └ /comparisons/gatographql-vs-wpgraphql
├ ○ /contact 3.27 kB 93 kB
├ ○ /demos 3.84 kB 1.31 MB
├ ● /demos/[slug] 6.46 kB 122 kB
├ ├ /demos/automatically-importing-new-posts-from-any-wordpress-rss-feed-daily
├ ├ /demos/automatically-sending-an-email-to-all-subscribers-notifying-of-a-new-post
├ ├ /demos/automatically-sync-post-featured-image-for-polylang
├ └ [+13 more paths]
├ ○ /developers 1.13 kB 122 kB
├ ○ /docs 174 B 84.8 kB
├ ○ /download 1.13 kB 122 kB
├ ○ /extensions 793 B 1.34 MB
├ ○ /extensions-reference 174 B 84.8 kB
├ λ /extensions-reference/[topic] 174 B 84.8 kB
├ ● /extensions-reference/[topic]/[slug] 158 B 121 kB
├ ● /extensions/[slug] 4.89 kB 1.34 MB
├ ├ /extensions/access-control
├ ├ /extensions/caching
├ ├ /extensions/custom-endpoints
├ └ [+7 more paths]
├ ○ /extensions/opengraph-image-1ptgva.png 0 B 0 B
├ ○ /extensions/twitter-image-1ptgva.png 0 B 0 B
├ ○ /features 2.38 kB 98.9 kB
├ ● /features/[slug] 7.38 kB 123 kB
├ ├ /features/access-control
├ ├ /features/api-hierarchy-and-endpoint-management
├ ├ /features/custom-endpoints
├ └ [+12 more paths]
├ ○ /features/opengraph-image-q698t4.png 0 B 0 B
├ ○ /features/twitter-image-q698t4.png 0 B 0 B
├ ○ /guides 174 B 84.8 kB
├ λ /guides/[topic] 174 B 84.8 kB
├ ● /guides/[topic]/[slug] 158 B 121 kB
├ ○ /highlights 4.26 kB 134 kB
├ ○ /howdy 5.48 kB 121 kB
├ ○ /library 174 B 84.8 kB
├ ● /library/[slug] 158 B 121 kB
├ ├ /library/add-a-mandatory-comments-block-to-post
├ ├ /library/add-missing-links-in-post
├ ├ /library/augment-data-from-an-external-api
├ └ [+49 more paths]
├ ○ /newsletter 3.75 kB 93.5 kB
├ ○ /opengraph-image.png 0 B 0 B
├ ○ /pricing 395 B 1.32 MB
├ ○ /refund-policy 6.13 kB 122 kB
├ ○ /robots.txt 0 B 0 B
├ ○ /shop 174 B 84.8 kB
├ ○ /shop/customer-portal 158 B 121 kB
├ ○ /shop/my-orders 158 B 121 kB
├ ○ /shop/success 1.13 kB 122 kB
├ ○ /sitemap.xml 0 B 0 B
├ ○ /slides 174 B 84.8 kB
├ ○ /slides/cover 3.66 kB 93.4 kB
├ λ /slides/extension-cover/[slug] 4.15 kB 93.9 kB
├ ○ /specials 174 B 84.8 kB
├ ○ /specials/wpbuilds 158 B 121 kB
├ ○ /support 3.12 kB 92.8 kB
├ ○ /tutorial 174 B 84.8 kB
├ ● /tutorial/[slug] 158 B 121 kB
├ ├ /tutorial/adapting-content-in-bulk
├ ├ /tutorial/automatically-adding-a-mandatory-block
├ ├ /tutorial/automatically-sending-newsletter-subscribers-from-instawp-to-mailchimp
├ └ [+26 more paths]
└ ○ /twitter-image.png 0 B 0 B
+ First Load JS shared by all 84.7 kB
├ chunks/1dd3208c-150aa526550611f4.js 53.4 kB
├ chunks/9997-9539fc6784a82a39.js 29.2 kB
└ other shared chunks (total) 2.07 kB
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses getStaticProps)
λ (Dynamic) server-rendered on demand using Node.js
(build.command completed in 28.6s)
@netlify/plugin-nextjs (onBuild event)
────────────────────────────────────────────────────────────────
@netlify/plugin-nextjs (onEnd event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onEnd completed in 6ms)
Save updated config
────────────────────────────────────────────────────────────────
(options.onEnd completed in 4ms)
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Your publish directory does not contain expected Next.js build output. Please check your build settings
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
Resolved config
build:
command: npm run build --prefix apps/gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next
publishOrigin: config
plugins:
- inputs: {}
origin: ui
package: '@netlify/plugin-nextjs'
redirects:
- from: /gatographql-vs-wprestapi
status: 301
to: /comparisons/gatographql-vs-wp-rest-api
- from: /gatographql-vs-wp-rest-api
status: 301
to: /comparisons/gatographql-vs-wp-rest-api
- from: /gatographql-vs-wpgraphql
status: 301
to: /comparisons/gatographql-vs-wpgraphql
- from: /tags
status: 301
to: /blog
- from: /tags/*
status: 301
to: /blog
- from: /recipes/*
status: 301
to: /tutorial/:splat
- from: /demo
status: 301
to: /tutorial/intro
- from: /about-us
status: 301
to: /about
- from: /guides/special-features/*
status: 301
to: /features/:splat
- from: /guides/intro
status: 301
to: /guides/intro/intro-to-graphql-and-gato-graphql
- from: /guides/query
status: 301
to: /guides/query/executing-queries-and-mutations
- from: /guides/use
status: 301
to: /guides/use/creating-a-custom-endpoint
- from: /guides/schema
status: 301
to: /guides/schema/namespacing-the-schema
- from: /guides/config
status: 301
to: /guides/config/installing-and-upgrading-a-bundle-or-extension
- from: /guides/augment
status: 301
to: /guides/augment/schema-extensions-via-introspection
- from: /guides/interact
status: 301
to: /guides/interact/working-with-custom-posts
- from: /guides/deep
status: 301
to: /guides/deep/fetching-dynamically-structured-data
- from: /guides/resources
status: 301
to: /guides/resources/graphql-best-practices
- from: /tutorial/complementing-wp-cli
status: 301
to: /guides/code/complementing-wp-cli
- from: /tutorial/dry-code-for-blocks-in-javascript-and-php
status: 301
to: /guides/code/dry-code-for-blocks-in-javascript-and-php
- from: /tutorial/exposing-public-and-private-endpoints
status: 301
to: /guides/code/exposing-public-and-private-endpoints
- from: /tutorial/feeding-data-to-blocks-in-the-editor
status: 301
to: /guides/code/feeding-data-to-blocks-in-the-editor
- from: /tutorial/injecting-multiple-resources-into-wp-cli
status: 301
to: /guides/code/injecting-multiple-resources-into-wp-cli
- from: /tutorial/mapping-js-components-to-gutenberg-blocks
status: 301
to: /guides/code/mapping-js-components-to-gutenberg-blocks
- from: /bundles
status: 301
to: /
- from: /bundles/all-in-one-toolbox-for-wordpress
status: 301
to: /
- from: /bundles/automated-content-translation-and-sync-for-wordpress-multisite
status: 301
to: /
- from: /bundles/better-wordpress-webhooks
status: 301
to: /
- from: /bundles/easy-wordpress-bulk-transform-and-update
status: 301
to: /
- from: /bundles/private-graphql-server-for-wordpress
status: 301
to: /
- from: /bundles/responsible-wordpress-public-api
status: 301
to: /
- from: /bundles/selective-content-import-export-and-sync-for-wordpress
status: 301
to: /
- from: /bundles/simplest-wordpress-content-translation
status: 301
to: /
- from: /bundles/tailored-wordpress-automator
status: 301
to: /
- from: /bundles/unhindered-wordpress-email-notifications
status: 301
to: /
- from: /bundles/versatile-wordpress-request-api
status: 301
to: /
- from: /bundles/content-translation
status: 301
to: /
- from: /bundles/public-api
status: 301
to: /
- from: /bundles/application-glue-and-automator
status: 301
to: /
- from: /bundles/all-extensions
status: 301
to: /
- from: /raffle
status: 302
to: /
- from: /black-friday
status: 302
to: /
- from: /wpbuilds
status: 301
to: /specials/wpbuilds
- from: /docs/dynamic-schema/ifttt-through-directives.html
status: 301
to: /architecture/ifttt-through-directives
- from: /docs/dynamic-schema/field-directive-based-versioning.html
status: 301
to: /architecture/field-directive-based-versioning
- from: /docs/architecture/cms-agnosticism.html
status: 301
to: /architecture/cms-agnosticism
- from: /docs/architecture/solid.html
status: 301
to: /architecture/solid
- from: /docs/architecture/code-first.html
status: 301
to: /architecture/code-first
- from: /docs/architecture/dataloading-engine.html
status: 301
to: /architecture/dataloading-engine
- from: /docs/architecture/decoupling-queries.html
status: 301
to: /architecture/decoupling-queries
- from: /docs/architecture/directive-design.html
status: 301
to: /architecture/directive-design
- from: /docs/architecture/directive-pipeline.html
status: 301
to: /architecture/directive-pipeline
- from: /docs/architecture/manipulating-field-resolution-order.html
status: 301
to: /architecture/manipulating-field-resolution-order
- from: /docs/architecture/nested-mutations-single-source-of-code.html
status: 301
to: /architecture/nested-mutations-single-source-of-code
- from: /docs/architecture/schema-type-directives.html
status: 301
to: /architecture/schema-type-directives
- from: /docs/architecture/subscribing-fields-to-types.html
status: 301
to: /architecture/subscribing-fields-to-types
- from: /docs/architecture/suppressing-n-plus-one-problem.html
status: 301
to: /architecture/suppressing-n-plus-one-problem
- from: /docs/architecture/using-components-instead-of-graphs.html
status: 301
to: /architecture/using-components-instead-of-graphs
- from: /guides/rapid-iteration-on-the-schema.html
status: 301
to: /
- from: /guides/versioning-fields-and-directives.html
status: 301
to: /features/field-and-directive-based-versioning
- from: /guides/localized-newsletter.html
status: 301
to: /
- from: /guides/building-cms-agnostic-api.html
status: 301
to: /architecture/cms-agnosticism
- from: /docs/architecture/*
status: 301
to: /
- from: /docs/caching/*
status: 301
to: /
- from: /docs/clients/*
status: 301
to: /
- from: /docs/dynamic-schema/*
status: 301
to: /
- from: /docs/extended/*
status: 301
to: /
- from: /docs/getting-started/*
status: 301
to: /
- from: /docs/going-further/*
status: 301
to: /
- from: /docs/operational/*
status: 301
to: /
- from: /docs/roadmap/*
status: 301
to: /
- from: /docs/schema-objects/*
status: 301
to: /
- from: /docs/troubleshooting/*
status: 301
to: /
- from: /library/import-post-from-wp-rss-feed
status: 301
to: /library/import-post-from-wordpress-rss-feed
- from: /library/import-post-from-wp-site
status: 301
to: /library/import-post-from-wordpress-site
- from: /library/export-post-to-wp-site
status: 301
to: /library/export-post-to-wordpress-site
- from: /features/graphical-clients
status: 301
to: /features/interactive-clients-and-user-interface
- from: /features/graphiql-client
status: 301
to: /features/interactive-clients-and-user-interface
- from: /features/voyager-client
status: 301
to: /features/interactive-clients-and-user-interface
- from: /features/predefined-persisted-queries
status: 301
to: /features
- from: /features/sensitive-data
status: 301
to: /features/security
- from: /features/enhanced-security
status: 301
to: /features/security
- from: /features/api-hierarchy
status: 301
to: /features/api-hierarchy-and-endpoint-management
- from: /features/endpoint-management
status: 301
to: /features/api-hierarchy-and-endpoint-management
- from: /features/schema-namespacing
status: 301
to: /features/custom-features
- from: /features/global-fields
status: 301
to: /features/custom-features
- from: /features/field-to-input
status: 301
to: /features/custom-features
- from: /features/composable-directives
status: 301
to: /features/custom-features
- from: /features/multifield-directives
status: 301
to: /features/custom-features
- from: /features/field-and-directive-based-versioning
status: 301
to: /features/custom-features
- from: /features/proactive-feedback
status: 301
to: /features/custom-features
- from: /features/public-private-schema
status: 301
to: /features/access-control
- from: /features/function-fields
status: 301
to: /features/schema-functions
- from: /features/function-directives
status: 301
to: /features/schema-functions
- from: /features/http-client
status: 301
to: /features/schema-functions
- from: /features/helper-fields
status: 301
to: /features/schema-functions
- from: /features/environment-fields
status: 301
to: /features/schema-functions
- from: /features/mutation-return-type
status: 301
to: /features
- from: /features/automation
status: 301
to: /features
- from: /features/integrations-with-3rdparty-plugins
status: 301
to: /features
redirectsOrigin: config
```
I’d really recommend against polluting the repo without getting a confirmation from support about thhis being a bug. Monorepos work fine (I deploy those on a daily basis).
Furthermore, if there’s an actual issue, us escalating it internally would make an actual difference than a user-submitted bug report that’s not yet confirmed.
Happy to take a look at this if you have a reproduction to share.
leoloso
November 18, 2024, 12:11am
6
Hi @hrishikesh thanks for your help.
Ok, I’ve added a comment on the GitHub issue stating to ignore it for the time being.
The issue is that when doing netlify deploy --build --context deploy-preview
with the monorepo:
The build
part appends the package directory (apps/gatographql
). to the destination folder
The deploy
part does not
Then, it gives error message:
Your publish directory does not contain expected Next.js build output. Please check your build settings
(The apps/gatographql/.next
folder was created properly)
The repo for my site (elaborate-cactus-b60dfa ) is private, so I replicated the configuration here:
Public repo to troubleshoot issues
The Build settings in Netlify is this one:
The complete output from running netlify deploy --build --context deploy-preview
locally is this one:
Netlify Build
────────────────────────────────────────────────────────────────
❯ Version
@netlify/build 29.36.3
❯ Flags
packagePath: apps/gatographql
❯ Current directory
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com
❯ Config file
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/netlify.toml
❯ Context
deploy-preview
❯ Using Next.js Runtime - v5.8.1
Cleaning up leftover files from previous builds
────────────────────────────────────────────────────────────────
(Pre cleanup completed in 13ms)
@netlify/plugin-nextjs (onPreBuild event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onPreBuild completed in 137ms)
build.command from netlify.toml
────────────────────────────────────────────────────────────────
$ npm run build --prefix apps/gatographql
> gatographql@0.1.0 build
> export $(cat .env | xargs) && NODE_OPTIONS=--max-old-space-size=8192 next build
▲ Next.js 14.1.3
- Environments: .env
Creating an optimized production build ...
Generated 379 documents in .contentlayer
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (230/230)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 31.9 kB 1.38 MB
├ ○ /_not-found 0 B 0 B
├ ○ /about 2.83 kB 124 kB
├ λ /api/deploy-algolia 0 B 0 B
├ ○ /architecture 174 B 84.8 kB
├ ● /architecture/[slug] 158 B 121 kB
├ ├ /architecture/cms-agnosticism
├ ├ /architecture/code-first
├ ├ /architecture/dataloading-engine
├ └ [+12 more paths]
├ ○ /blog 2.24 kB 1.31 MB
├ ● /blog/[slug] 1.52 kB 123 kB
├ ├ /blog/introducing-headless-wordpress-without-wordpress
├ ├ /blog/released-v70-to-power-standalone-plugins
├ ├ /blog/gatographql-gets-streamlined
├ └ [+46 more paths]
├ ○ /comparisons 4.6 kB 101 kB
├ ● /comparisons/[slug] 2.68 kB 124 kB
├ ├ /comparisons/gatographql-vs-wp-rest-api
├ └ /comparisons/gatographql-vs-wpgraphql
├ ○ /contact 3.27 kB 93 kB
├ ○ /demos 3.84 kB 1.31 MB
├ ● /demos/[slug] 6.46 kB 122 kB
├ ├ /demos/automatically-importing-new-posts-from-any-wordpress-rss-feed-daily
├ ├ /demos/automatically-sending-an-email-to-all-subscribers-notifying-of-a-new-post
├ ├ /demos/automatically-sync-post-featured-image-for-polylang
├ └ [+13 more paths]
├ ○ /developers 1.13 kB 122 kB
├ ○ /docs 174 B 84.8 kB
├ ○ /download 1.13 kB 122 kB
├ ○ /extensions 793 B 1.34 MB
├ ○ /extensions-reference 174 B 84.8 kB
├ λ /extensions-reference/[topic] 174 B 84.8 kB
├ ● /extensions-reference/[topic]/[slug] 158 B 121 kB
├ ● /extensions/[slug] 4.89 kB 1.34 MB
├ ├ /extensions/access-control
├ ├ /extensions/caching
├ ├ /extensions/custom-endpoints
├ └ [+7 more paths]
├ ○ /extensions/opengraph-image-1ptgva.png 0 B 0 B
├ ○ /extensions/twitter-image-1ptgva.png 0 B 0 B
├ ○ /features 2.38 kB 98.9 kB
├ ● /features/[slug] 7.38 kB 123 kB
├ ├ /features/access-control
├ ├ /features/api-hierarchy-and-endpoint-management
├ ├ /features/custom-endpoints
├ └ [+12 more paths]
├ ○ /features/opengraph-image-q698t4.png 0 B 0 B
├ ○ /features/twitter-image-q698t4.png 0 B 0 B
├ ○ /guides 174 B 84.8 kB
├ λ /guides/[topic] 174 B 84.8 kB
├ ● /guides/[topic]/[slug] 158 B 121 kB
├ ○ /highlights 4.26 kB 134 kB
├ ○ /howdy 5.48 kB 121 kB
├ ○ /library 174 B 84.8 kB
├ ● /library/[slug] 158 B 121 kB
├ ├ /library/add-a-mandatory-comments-block-to-post
├ ├ /library/add-missing-links-in-post
├ ├ /library/augment-data-from-an-external-api
├ └ [+49 more paths]
├ ○ /newsletter 3.75 kB 93.5 kB
├ ○ /opengraph-image.png 0 B 0 B
├ ○ /pricing 395 B 1.32 MB
├ ○ /refund-policy 6.13 kB 122 kB
├ ○ /robots.txt 0 B 0 B
├ ○ /shop 174 B 84.8 kB
├ ○ /shop/customer-portal 158 B 121 kB
├ ○ /shop/my-orders 158 B 121 kB
├ ○ /shop/success 1.13 kB 122 kB
├ ○ /sitemap.xml 0 B 0 B
├ ○ /slides 174 B 84.8 kB
├ ○ /slides/cover 3.66 kB 93.4 kB
├ λ /slides/extension-cover/[slug] 4.15 kB 93.9 kB
├ ○ /specials 174 B 84.8 kB
├ ○ /specials/wpbuilds 158 B 121 kB
├ ○ /support 3.12 kB 92.8 kB
├ ○ /tutorial 174 B 84.8 kB
├ ● /tutorial/[slug] 158 B 121 kB
├ ├ /tutorial/adapting-content-in-bulk
├ ├ /tutorial/automatically-adding-a-mandatory-block
├ ├ /tutorial/automatically-sending-newsletter-subscribers-from-instawp-to-mailchimp
├ └ [+26 more paths]
└ ○ /twitter-image.png 0 B 0 B
+ First Load JS shared by all 84.7 kB
├ chunks/1dd3208c-150aa526550611f4.js 53.4 kB
├ chunks/9997-9539fc6784a82a39.js 29.2 kB
└ other shared chunks (total) 2.07 kB
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses getStaticProps)
λ (Dynamic) server-rendered on demand using Node.js
(build.command completed in 28.6s)
@netlify/plugin-nextjs (onBuild event)
────────────────────────────────────────────────────────────────
@netlify/plugin-nextjs (onEnd event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onEnd completed in 6ms)
Save updated config
────────────────────────────────────────────────────────────────
(options.onEnd completed in 4ms)
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Your publish directory does not contain expected Next.js build output. Please check your build settings
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onBuild" event in "@netlify/plugin-nextjs" from Netlify app
Resolved config
build:
command: npm run build --prefix apps/gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next
publishOrigin: config
plugins:
- inputs: {}
origin: ui
package: '@netlify/plugin-nextjs'
Notice that the publish
var was resolved to /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/.next
, but it should be /Users/leo/GitRepos/GitHub/Sites/leoloso/gatographql.com/apps/gatographql/.next
(the package directory apps/gatographql
is missing).
Also, removing dependency "next": "^14.1.3"
will then install runtime @netlify/plugin-nextjs@4.41.3
, and then it works fine
I think, the correct command to deploy is:
netlify deploy --build --context deploy-preview --filter gatographql
In your app/gatographql/netlify.toml
, you should have:
[build]
command = "npm run build -w gatographql"
publish = "./apps/gatographql/.next/"
[build.environment]
NODE_OPTIONS = "--max-old-space-size=8192"
[[plugins]]
package = "@netlify/plugin-nextjs"
leoloso
November 21, 2024, 3:00am
8
Thanks @hrishikesh I added your changes, but now it fails with a different error message:
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Failed publishing static content
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onPostBuild" event in "@netlify/plugin-nextjs" from netlify.toml and package.json
Resolved config
build:
base: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql
command: npm run build -w gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/apps/gatographql/.next
publishOrigin: config
Notice it says:
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/apps/gatographql/.next
…so apps/gatographql/apps/gatographql/
is duplicated…
Btw, I’ve removed the “Package directory” value from the Build settings in Netlify, yet it still says:
❯ Flags
packagePath: apps/gatographql
Is that right?
Btw2, running netlify dev --filter gatographql
works well.
Full log:
Netlify Build
────────────────────────────────────────────────────────────────
❯ Version
@netlify/build 29.36.3
❯ Flags
packagePath: apps/gatographql
❯ Current directory
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites
❯ Config file
/Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/netlify.toml
❯ Context
deploy-preview
❯ Using Next.js Runtime - v5.8.1
@netlify/plugin-nextjs (onPreBuild event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onPreBuild completed in 6ms)
build.command from netlify.toml
────────────────────────────────────────────────────────────────
$ npm run build -w gatographql
> gatographql@0.1.0 build
> export $(cat .env | xargs) && NODE_OPTIONS=--max-old-space-size=8192 next build
▲ Next.js 14.2.18
- Environments: .env
Creating an optimized production build ...
Generated 378 documents in .contentlayer
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (230/230)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 32.7 kB 1.39 MB
├ ○ /_not-found 178 B 87.5 kB
├ ○ /about 3.1 kB 139 kB
├ ƒ /api/deploy-algolia 0 B 0 B
├ ○ /architecture 178 B 87.5 kB
├ ● /architecture/[slug] 157 B 124 kB
├ ├ /architecture/cms-agnosticism
├ ├ /architecture/code-first
├ ├ /architecture/dataloading-engine
├ └ [+12 more paths]
├ ○ /blog 4.45 kB 1.31 MB
├ ● /blog/[slug] 1.37 kB 128 kB
├ ├ /blog/introducing-headless-wordpress-without-wordpress
├ ├ /blog/released-v70-to-power-standalone-plugins
├ ├ /blog/gatographql-gets-streamlined
├ └ [+46 more paths]
├ ○ /comparisons 3.67 kB 116 kB
├ ● /comparisons/[slug] 4.91 kB 137 kB
├ ├ /comparisons/gatographql-vs-wp-rest-api
├ └ /comparisons/gatographql-vs-wpgraphql
├ ○ /contact 3.44 kB 95.9 kB
├ ○ /demos 6.42 kB 1.31 MB
├ ● /demos/[slug] 5.79 kB 129 kB
├ ├ /demos/automatically-importing-new-posts-from-any-wordpress-rss-feed-daily
├ ├ /demos/automatically-sending-an-email-to-all-subscribers-notifying-of-a-new-post
├ ├ /demos/automatically-sync-post-featured-image-for-polylang
├ └ [+13 more paths]
├ ○ /developers 257 B 134 kB
├ ○ /docs 178 B 87.5 kB
├ ○ /download 257 B 134 kB
├ ○ /extensions 4.28 kB 1.36 MB
├ ○ /extensions-reference 178 B 87.5 kB
├ ƒ /extensions-reference/[topic] 178 B 87.5 kB
├ ● /extensions-reference/[topic]/[slug] 157 B 124 kB
├ ● /extensions/[slug] 5.03 kB 1.36 MB
├ ├ /extensions/access-control
├ ├ /extensions/caching
├ ├ /extensions/custom-endpoints
├ └ [+7 more paths]
├ ○ /extensions/opengraph-image-1ptgva.png 0 B 0 B
├ ○ /extensions/twitter-image-1ptgva.png 0 B 0 B
├ ○ /features 5.79 kB 114 kB
├ ● /features/[slug] 5.57 kB 138 kB
├ ├ /features/access-control
├ ├ /features/api-hierarchy-and-endpoint-management
├ ├ /features/custom-endpoints
├ └ [+12 more paths]
├ ○ /features/opengraph-image-q698t4.png 0 B 0 B
├ ○ /features/twitter-image-q698t4.png 0 B 0 B
├ ○ /guides 178 B 87.5 kB
├ ƒ /guides/[topic] 178 B 87.5 kB
├ ● /guides/[topic]/[slug] 157 B 124 kB
├ ○ /highlights 6.1 kB 138 kB
├ ○ /howdy 8.25 kB 134 kB
├ ○ /library 178 B 87.5 kB
├ ● /library/[slug] 156 B 124 kB
├ ├ /library/add-a-mandatory-comments-block-to-post
├ ├ /library/add-missing-links-in-post
├ ├ /library/augment-data-from-an-external-api
├ └ [+49 more paths]
├ ○ /newsletter 416 B 96.3 kB
├ ○ /opengraph-image.png 0 B 0 B
├ ○ /pricing 282 B 1.34 MB
├ ○ /refund-policy 5.08 kB 124 kB
├ ○ /robots.txt 0 B 0 B
├ ○ /shop 178 B 87.5 kB
├ ○ /shop/customer-portal 157 B 123 kB
├ ○ /shop/my-orders 157 B 123 kB
├ ○ /shop/success 257 B 134 kB
├ ○ /sitemap.xml 0 B 0 B
├ ○ /slides 178 B 87.5 kB
├ ○ /slides/cover 4.28 kB 96.7 kB
├ ƒ /slides/extension-cover/[slug] 4.71 kB 97.2 kB
├ ○ /specials 178 B 87.5 kB
├ ○ /specials/wpbuilds 4.75 kB 133 kB
├ ○ /support 3.3 kB 95.7 kB
├ ○ /tutorial 178 B 87.5 kB
├ ● /tutorial/[slug] 157 B 124 kB
├ ├ /tutorial/adapting-content-in-bulk
├ ├ /tutorial/automatically-adding-a-mandatory-block
├ ├ /tutorial/automatically-sending-newsletter-subscribers-from-instawp-to-mailchimp
├ └ [+26 more paths]
└ ○ /twitter-image.png 0 B 0 B
+ First Load JS shared by all 87.3 kB
├ chunks/1528-fdcf07ae2065d021.js 31.7 kB
├ chunks/1dd3208c-fc3e284b884115f7.js 53.6 kB
└ other shared chunks (total) 2 kB
○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses getStaticProps)
ƒ (Dynamic) server-rendered on demand
(build.command completed in 59.7s)
@netlify/plugin-nextjs (onBuild event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onBuild completed in 43.5s)
Functions bundling
────────────────────────────────────────────────────────────────
Packaging Functions from apps/gatographql/.netlify/functions-internal directory:
- ___netlify-server-handler/___netlify-server-handler.mjs
(Functions bundling completed in 1.2s)
Edge Functions bundling
────────────────────────────────────────────────────────────────
(Edge Functions bundling completed in 368ms)
@netlify/plugin-nextjs (onPostBuild event)
────────────────────────────────────────────────────────────────
@netlify/plugin-nextjs (onEnd event)
────────────────────────────────────────────────────────────────
(@netlify/plugin-nextjs onEnd completed in 4ms)
Save updated config
────────────────────────────────────────────────────────────────
(options.onEnd completed in 4ms)
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Failed publishing static content
Plugin details
Package: @netlify/plugin-nextjs
Version: 5.8.1
Repository: git+https://github.com/netlify/next-runtime.git
npm link: https://www.npmjs.com/package/@netlify/plugin-nextjs
Report issues: https://github.com/netlify/next-runtime/issues
Error location
In "onPostBuild" event in "@netlify/plugin-nextjs" from netlify.toml and package.json
Resolved config
build:
base: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql
command: npm run build -w gatographql
commandOrigin: config
environment:
- NODE_OPTIONS
publish: /Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/apps/gatographql/.next
publishOrigin: config
plugins:
- inputs: {}
origin: config
package: '@netlify/plugin-nextjs'
redirectsOrigin: inline
Unfortunately, that error is vague and comes from: opennextjs-netlify/src/build/content/static.ts at 00e3a4be19bf8428ea6ce1ed2ae74a8ac8375532 · opennextjs/opennextjs-netlify . So it can fail in either of those lines and return the same issue.
Since you’re building locally, could you modify the file in node_modules
directory to log out the error which might have additional details?
leoloso
December 2, 2024, 1:00am
10
Hi @hrishikesh I modified that line to:
ctx.failBuild("Failed publishing static content (Modified output)", error);
Now the output printed:
Plugin "@netlify/plugin-nextjs" failed
────────────────────────────────────────────────────────────────
Error message
Error: Failed publishing static content (Modified output)
ENOENT: no such file or directory, rename '/Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/apps/gatographql/.next' -> '/Users/leo/GitRepos/GitHub/Sites/leoloso/gatowebsites/apps/gatographql/.netlify/.next'
It’s hard for me to debug this while having no visibility into your side of things, but here’s an example monorepo: hrishikesh-k/blog and its config: blog/packages/site/netlify.toml at main · hrishikesh-k/blog . The important bits:
Your netlify.toml
should exist in your site’s directory (in your example, it should be in /apps/gatographql/
)
The netlify.toml
should have the following:
[build]
command = "npm run build -w=package-name" # in your example this would be npm run build -w=gatographql
publish = "./apps/gatographql/.next/"
[[plugins]]
package = "@netlify/plugin-nextjs"
You should run CLI from the root of the repo. The command for dev server would be:
netlify dev --filter=gatographql
while the command to deploy would be:
netlify deploy --build --filter=gatographql
This is just a repitition of most of what’s already discussed in this thread and is also how every other monorepo user is deploying their site to Netlify. If yours still doesn’t work, I’d need to see the repo so I can reproduce the issue if it exists.
leoloso
December 9, 2024, 12:07am
12
Hi @hrishikesh OK I’ve made my repo public:
Website for Gato GraphQL
There’s a branch “Fix-issue-with-Netlify” with the changes you mentioned:
Please checkout that branch, and then attempt to deploy the website under apps/gatographql
:
cd apps/gatographql
netlify deploy --build --context deploy-preview --filter gatographql
… and you’ll see the problem
Thanks
I’m trying out the repo now, but you mentioned:
leoloso:
cd apps/gatographql
which is exactly what I’m telling you not to do:
That’s most likely the issue, but I’ll confirm once I run it myself locally.
Can confirm, it worked fine.
leoloso
December 16, 2024, 12:51am
15
@hrishikesh I confirm it works well
Thanks so much for your help