我在 NUXT JS 上构建了我的应用程序并将其部署在 Vercel 上,但出现如下错误。
当我打开功能日志时,它向我显示的是以下内容。
这是我在函数 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
任何调试此问题的帮助将不胜感激,我使用 Nuxt 2
此错误是在部署 Web 应用程序后出现的。这是 checkly 的错误。 Checkly 检查每个页面是否加载正常。如果任何页面损坏,都会抛出错误。
因此,在本地,您可以通过一点解决方案检查您的网络应用程序。如果您的所有页面都根据每个预期(API 实现或错误)进行处理。那么你的问题就解决了。
您可以将 now/node 更改为 vercel
{
"version": 2,
"builds": [{
"src": "src/index.js",
"use": "@vercel/node"
}],
"routes": [{
"src": "/(.*)",
"dest": "src/index.js"
}]
}
{
"version": 2,
"builds": [
{
"src": "index.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "index.js"
}
]
}
在 package.json 文件中添加构建脚本
“构建”:“[我的框架]构建--输出公共”
"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"
},