Error when visiting a deployed site built with nx, next.js

I have a next.js app (built with nx) which we have deployed several times to netlify in the past and everything works well each time.

In the past few days, we suddenly noticed that we are unable to access the index of the site even when the build completes successfully. Instead, we get an error with the following message:

"errorType": "Error",
"errorMessage": "ENOENT: no such file or directory, chdir '/var/task' -> '/var/task/apps/homepage'",
"trace": [
"Error: ENOENT: no such file or directory, chdir '/var/task' -> '/var/task/apps/homepage'",
"    at process.wrappedChdir [as chdir] (internal/bootstrap/switches/does_own_process_state.js:116:14)",
"    at /var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:19:13",
"    at Object.<anonymous> (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:106:3)",
"    at Module._compile (internal/modules/cjs/loader.js:1085:14)",
"    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
"    at Module.load (internal/modules/cjs/loader.js:950:32)",
"    at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
"    at Module.require (internal/modules/cjs/loader.js:974:19)",
"    at require (internal/modules/cjs/helpers.js:93:18)",
"    at Object.<anonymous> (/var/task/___netlify-handler.js:1:18)"

Below is what my netlify.toml file looks like, I have just added the next.js plugin with the hope that it solves the problem, although I did not need the plugin previously.

  publish = "dist/apps/homepage/.next"

  command = "yarn build"

  environment = { NODE_VERSION = "17.7.1", NODE_ENV = "development", 
  NX_NEXT_PUBLIC_API_MODE = "development" }

package = "@netlify/plugin-nextjs"

I am sure this app works, and that the publish directory is correct as I have tested it locally

  • with yarn start
  • and the associated Dockerfile which we use for eventual deployment also still works (I am not trying to use the docker process on netlify, I believe that is not supported)

App URL :

Looking forward to helpful replies :pray:t3:

1 Like

In our team we are experiencing same issue starting from today. Yesterday everything worked well

hi all,

are you still noticing these errors? are they still occurring, or did they go away?

Hi @Perry, yes we still experience the same issue currently.

Hey all,

This was a bug introduced with v4.2.8 of the plugin. At this point, 4.2.7 should work fine. Could you try to downgrade?

Thanks @hrishikesh.

It seems the issue has been resolved in the v4.3.1 plugin. Deployment works as expected now.

1 Like

Thanks so much for coming back and letting us know, @c_room. Happy building :rocket: