next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

[Bug]: ENOENT internal error with monorepo setup

Open leethree opened this issue 6 months ago • 6 comments

Summary

I'm trying to setup build in a monorepo according to Netlify's guide. But it doesn't work with this plugin because of an internal error.

A link to a reproduction repository

repo is private

Expected Result

Build successfully

Actual Result

Build failed due to plugin error.

Plugin "@netlify/plugin-nextjs" internal error

Error: ENOENT: no such file or directory, copyfile '.netlify/functions-internal/_ipx/imageconfig.json' -> '/opt/build/repo/app/.netlify/edge-functions/ipx/imageconfig.json'

Steps to reproduce

We have a monorepo with a Next.js app in the app directory.

The package directory is set in Netlify settings: image

Next Runtime version

4.41.3

Is your issue related to the app directory?

  • [ ] Yes, I am using the app directory

More information about your build

  • [ ] I am building using the CLI
  • [X] I am building using file-based configuration (netlify.toml)

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml`
[build]
command = "yarn workspace @/app build"
publish = "app/.next"

[build.environment]
NODE_VERSION = "20"
NETLIFY_USE_YARN = "true"
AWS_LAMBDA_JS_RUNTIME = "nodejs20.x"
NEXT_FORCE_EDGE_IMAGES = "true"

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

Builds logs (or link to your logs)

Build logs
11:16:07 AM: Plugin "@netlify/plugin-nextjs" internal error                
11:16:07 AM: ────────────────────────────────────────────────────────────────
11:16:07 AM: ​
11:16:07 AM:   Error message
11:16:07 AM:   Error: ENOENT: no such file or directory, copyfile ".netlify/functions-internal/_ipx/imageconfig.json" -> "/opt/build/repo/app/.netlify/edge-functions/ipx/imageconfig.json"
11:16:07 AM: ​
11:16:07 AM:   Plugin details
11:16:07 AM:   Package:        @netlify/plugin-nextjs
11:16:07 AM:   Version:        4.41.3
11:16:07 AM:   Repository:     git+https://github.com/netlify/next-runtime.git
11:16:07 AM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
11:16:07 AM:   Report issues:  https://github.com/netlify/next-runtime/issues
11:16:07 AM: ​
11:16:07 AM:   Error location
11:16:07 AM:   In "onBuild" event in "@netlify/plugin-nextjs" from netlify.toml and package.json
11:16:07 AM: ​
11:16:07 AM:   Error properties
11:16:07 AM:   {
11:16:07 AM:     errno: -2,
11:16:07 AM:     code: "ENOENT",
11:16:07 AM:     syscall: "copyfile",
11:16:07 AM:     path: ".netlify/functions-internal/_ipx/imageconfig.json",
11:16:07 AM:     dest: "/opt/build/repo/app/.netlify/edge-functions/ipx/imageconfig.json"
11:16:07 AM:   }
11:16:07 AM: ​
11:16:07 AM:   Resolved config
11:16:07 AM:   build:
11:16:07 AM:     command: yarn workspace @/app build
11:16:07 AM:     commandOrigin: config
11:16:07 AM:     environment:
11:16:07 AM:       - APP_ENV
11:16:07 AM:       - REVIEW_ID
11:16:07 AM:       - NODE_VERSION
11:16:07 AM:       - NETLIFY_USE_YARN
11:16:07 AM:       - AWS_LAMBDA_JS_RUNTIME
11:16:07 AM:       - NEXT_FORCE_EDGE_IMAGES
11:16:07 AM:       - NEXT_PRIVATE_TARGET
11:16:07 AM:     publish: /opt/build/repo/app/.next
11:16:07 AM:     publishOrigin: config
11:16:07 AM:   plugins:
11:16:07 AM:     - inputs: {}
11:16:07 AM:       origin: config
11:16:07 AM:       package: "@netlify/plugin-nextjs"
11:16:07 AM: Build failed due to an internal system error: Build script returned non-zero exit code: 4

leethree avatar Feb 05 '24 12:02 leethree