Udemezue John
Udemezue John

Reputation: 68

I get "This Serverless Function has crashed." When I deploy my NUXT js app to Vercel

I built my app on NUXT JS and deployed it on Vercel, but I get the error as shown below.

enter image description here

When I opened the function log, here is what it showed me.

enter image description here

Here is a full description of the error code I get in the functions Log.

[GET] /
03:25:28:10
WARN  /var/task/content does not exist
ℹ Parsed 0 files in 203.10 seconds
FATAL  ENOENT: no such file or directory, mkdir '/var/task/.nuxt/dist/client'
2022-06-18T02:25:28.277Z    d7a5445e-ee11-4de0-b976-042d56036dc7    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/static/sw.js'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/static/sw.js","stack":["Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:199:34)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

[GET] /
03:25:28:00
WARN  /var/task/content does not exist
ℹ Parsed 0 files in 0.0 seconds
FATAL  ENOENT: no such file or directory, mkdir '/var/task/.nuxt/dist/client'
2022-06-18T02:25:29.079Z    f196113c-cf3a-4725-85fa-75f87fa94c50    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/static/sw.js'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/static/sw.js","stack":["Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:199:34)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred
[GET] /
03:25:27:61
WARN  /var/task/content does not exist
ℹ Parsed 0 files in 144.5 seconds
FATAL  ENOENT: no such file or directory, mkdir '/var/task/.nuxt/dist/client'
2022-06-18T02:25:27.798Z    39e75c36-f6b6-4654-89ba-b0d9c90ae9ad    ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","reason":{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, open '/var/task/static/sw.js'","code":"ENOENT","errno":-2,"syscall":"open","path":"/var/task/static/sw.js","stack":["Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open '/var/task/static/sw.js'","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:199:34)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

Any help debugging this would be appreciated and I use Nuxt 2

Upvotes: 1

Views: 11630

Answers (3)

Keshav Gera
Keshav Gera

Reputation: 11254

{
    "version": 2,
    "builds": [
        {
            "src": "index.js",
            "use": "@vercel/node"
        }
    ],
    "routes": [
        {
            "src": "/(.*)",
            "dest": "index.js"
        }
    ]
   
}

Add build script in your package.json file

"build": "[my-framework] build --output public"

 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon src/index.js",
    "dev": "nodemon src/index.js",
    "build": "[my-framework] build --output public"
  },

Upvotes: 0

Dangeagle
Dangeagle

Reputation: 1

You can change the now/node to vercel

{
  "version": 2,
  "builds": [{
    "src": "src/index.js",
    "use": "@vercel/node"
  }],
  "routes": [{
    "src": "/(.*)",
    "dest": "src/index.js"
  }]
}

Upvotes: 0

Linkan kumar Sahu
Linkan kumar Sahu

Reputation: 11

This error comes after deployment of your web app. This is an error by checkly. Checkly checks that is every page is loading fine or not. If any of the page will break it will throw the error.

So in local you are checking your web app in one point of solution. if your all pages are handle accroding to every prospective(api fulfillment or error). Then your issue will be solved.

Upvotes: 1

Related Questions