Nuxt app + Vercel deployment : Error on Serverless Functions
Getting this after setting up vervel-builder on my Nuxt app.
2021-08-10T23:59:29.549Z undefined ERROR Uncaught Exception {"errorType":"Error","errorMessage":"Could not load Nuxt configuration. Make sure all dependencies are listed in package.json dependencies or in serverFiles within builder options:\n Error: Cannot find module 'esm'\nRequire stack:\n- /var/task/vercel__launcher.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","stack":["Error: Could not load Nuxt configuration. Make sure all dependencies are listed in package.json dependencies or in serverFiles within builder options:"," Error: Cannot find module 'esm'","Require stack:","- /var/task/vercel__launcher.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at Object.<anonymous> (/var/task/vercel__launcher.js:23:13)"," 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:14)"," at Module.require (internal/modules/cjs/loader.js:974:19)"," at require (internal/modules/cjs/helpers.js:92:18)"," at _tryRequire (/var/runtime/UserFunction.js:75:12)"," at _loadUserApp (/var/runtime/UserFunction.js:95:12)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"]}
Unknown application error occurred
Error
This is the state of vercel.json. Any tips?
{
"version": 2,
"builds": [
{
"src": "nuxt.config.js",
"use": "@nuxtjs/vercel-builder",
"config": {
"serverFiles": ["server-middleware/**"]
}
}
],
"routes": [
{
"src": "/sw.js",
"continue": true,
"headers": {
"Cache-Control": "public, max-age=0, must-revalidate",
"Service-Worker-Allowed": "/"
}
},
{
"src": "/api/contents/(?<id>[^/]+)",
"dest": "/api/contents/[id].js?id=$id",
"methods": ["GET", "OPTIONS"],
"headers": {
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type"
}
},
{
"src": "/api/(.*)",
"dest": "/api/$1.js",
"methods": ["GET", "OPTIONS"],
"headers": {
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type"
}
}
]
}
Check out https://github.com/nuxt/vercel-builder/issues/602#issuecomment-886953542, https://github.com/nuxt/vercel-builder/issues/589#issuecomment-868639430, and similar issues: https://github.com/nuxt/vercel-builder/issues/545.
If none of those comments/issues helps you, do reply with a reproduction and I'll take a look.
The solution was to yarn add esm. It would be great if you guys add this in the docs. Because I had a basically boilerplate app from the nuxt generator and trying to get it into vercel and faced this.
Thanks so much!
I had to move 'em dependencies from dev to dependencies