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.
[build]
publish = "dist/apps/homepage/.next"
command = "yarn build"
environment = { NODE_VERSION = "17.7.1", NODE_ENV = "development",
NX_NEXT_PUBLIC_API_MODE = "development" }
[[plugins]]
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 : https://lp2-app.netlify.app
Looking forward to helpful replies