Vercel部署无法从“ /var/task/api/index.js”解析“〜/ api / index.js”

时间:2020-08-21 07:04:18

标签: nuxt.js vercel

我的应用程序部署在vercel上。但是,它不起作用。在功能日志中,它具有以下内容

FATAL  Cannot resolve "~/api/index.js" from "/var/task/api/index.js"
at Resolver.resolvePath (node_modules/@nuxt/core/dist/core.js:572:11)
at Server._requireMiddleware (node_modules/@nuxt/server/dist/server.js:799:32)
at Server._normalizeMiddleware (node_modules/@nuenter code herext/server/dist/server.js:756:25)
at Server.resolveMiddleware (node_modules/@nuxt/server/dist/server.js:824:23)
at Server.useMiddleware (node_modules/@nuxt/server/dist/server.js:849:36)
at Server.setupMiddleware (node_modules/@nuxt/server/dist/server.js:707:12)
at async Server.ready (node_modules/@nuxt/server/dist/server.js:637:5)
at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:719:7)
2020-08-21T06:58:37.024Z    da066c7e-660f-4f4e-b080-9dfca786aa73    ERROR   λ Error while 
initializing nuxt: Error: Cannot resolve "~/api/index.js" from "/var/task/api/index.js"
at Resolver.resolvePath (/var/task/node_modules/@nuxt/core/dist/core.js:572:11)
at Server._requireMiddleware (/var/task/node_modules/@nuxt/server/dist/server.js:799:32)
at Server._normalizeMiddleware (/var/task/node_modules/@nuxt/server/dist/server.js:756:25)
at Server.resolveMiddleware (/var/task/node_modules/@nuxt/server/dist/server.js:824:23)
at Server.useMiddleware (/var/task/node_modules/@nuxt/server/dist/server.js:849:36)
at Server.setupMiddleware (/var/task/node_modules/@nuxt/server/dist/server.js:707:12)
at async Server.ready (/var/task/node_modules/@nuxt/server/dist/server.js:637:5)
at async Nuxt._init (/var/task/node_modules/@nuxt/core/dist/core.js:719:7)
RequestId: da066c7e-660f-4f4e-b080-9dfca786aa73 Error: Runtime exited with error: exit status 1
Runtime.ExitError'

1 个答案:

答案 0 :(得分:1)

您遵循Nuxt-Vercel Builder并正确配置了serverMiddleware吗?

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["api/**"]
      }
    }
  ]
}