serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

Error: ENOENT: no such file or directory _app.js.nft.json/503 Cloudfront error

Open anonymouscatcher opened this issue 2 years ago • 2 comments

"next": "^12.1.6"

serverless.yml

app-name:
  component: '@sls-next/[email protected]'
  inputs:
    useServerlessTraceTarget: true
   ****

next.config.js

  experimental: {
    outputStandalone: true
  },

Issue Summary

503 Cloudfront errors, similar to #713 #819, When I add outputStandalone it throws an error which is Error: ENOENT: no such file or directory _app.js.nft.json and when I removed it it deploys successfully but then I get 503 error.

logs

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read property '0' of undefined",
    "stack": [
        "TypeError: Cannot read property '0' of undefined",
        "    at Runtime.handler$1 [as handler] (/var/task/index.js:893:34)",
        "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
    ]
}

anonymouscatcher avatar Jun 15 '22 08:06 anonymouscatcher

I ran test with cloud front ab test, and this is the log:

{
  "errorType": "Error",
  "errorMessage": "Cannot find module './chunks/../commons.js'\nRequire stack:\n- /var/task/webpack-runtime.js\n- /var/task/pages/_error.js\n- /var/task/default-handler-0a0dc009.js\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
  "trace": [
    "Error: Cannot find module './chunks/../commons.js'",
    "Require stack:",
    "- /var/task/webpack-runtime.js",
    "- /var/task/pages/_error.js",
    "- /var/task/default-handler-0a0dc009.js",
    "- /var/task/index.js",
    "- /var/runtime/UserFunction.js",
    "- /var/runtime/index.js",
    "    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:746:27)",
    "    at Module.require (internal/modules/cjs/loader.js:974:19)",
    "    at require (internal/modules/cjs/helpers.js:101:18)",
    "    at Object.__webpack_require__.f.require (/var/task/webpack-runtime.js:192:28)",
    "    at /var/task/webpack-runtime.js:100:40",
    "    at Array.reduce (<anonymous>)",
    "    at Function.__webpack_require__.e (/var/task/webpack-runtime.js:99:67)",
    "    at Array.map (<anonymous>)",
    "    at Function.__webpack_require__.X (/var/task/webpack-runtime.js:144:22)"
  ]
}

anonymouscatcher avatar Jun 16 '22 10:06 anonymouscatcher

I found a way to replicate the issue, if you add target: 'serverless' on the next.config.js I get the same issue of serveless deploy > Build error occurred [Error: ENOENT: no such file or directory, open '/.next/server/pages/_app.js.nft.json'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/.next/server/pages/_app.js.nft.json' }

JeffersonRojas avatar Jun 22 '22 07:06 JeffersonRojas

I encountered the same error. Looks like NextJS 12 is not supported yet...

aeshaynes avatar Oct 12 '22 15:10 aeshaynes