[Bug]: ENOENT internal error with monorepo setup
leethree opened this issue · 7 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:
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
- 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
It works if edge images is turned off
I think the issue is the following copy command does not take into consideration of the package path:
next-runtime/packages/runtime/src/helpers/edge.ts
Lines 496 to 499 in aad8712
@leethree any update on this issue, we are getting the same error?
@seeratawan01 Unfortunately no one from Netlify has responded. We manually patched the library to make it work. See #2419
Hey @leethree @seeratawan01,
We've been busy working on our new v5 runtime which should help to solve these issues.
You can try it out now by following the instructions here: Netlify Next.js
Let us know if you still have problems.
Thanks!
@MarcL thanks, but we have already shifted to vercel last week because of this issue.
We've now released our v5
version of the runtime which should have much improved monorepo issues. Closing this issue but feel free to open another issue if people are still seeing problems.