Netlify Site: clever-panda-a35c8f.netlify.app
I deployed a Nuxt 3 application that consist of a simple application where authenticated users will be able to see “Content Lessons”. In this content Lessons, I call an API route if the user started watching a video. This API route uses Nuxt’s api
folder, so the route can be reached under the path /api/saveProgress
.
When doing this request on my deployed application, I receive the following error:
Cannot find package '@sanity/client' imported from /var/task/chunks/saveProgress.post.mjs
Checking the functions logs, I also see something similar
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR [nuxt] [request error] [unhandled] [500] Cannot find package '@sanity/client' imported from /var/task/chunks/saveProgress.post.mjs
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at new NodeError (node:internal/errors:387:5)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at packageResolve (node:internal/modules/esm/resolve:852:9)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at moduleResolve (node:internal/modules/esm/resolve:901:20)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at defaultResolve (node:internal/modules/esm/resolve:1115:11)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at nextResolve (node:internal/modules/esm/loader:163:28)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
Aug 30, 12:53:32 AM: 6acd0ab8 ERROR at link (node:internal/modules/esm/module_job:75:36)
I understand that Netlify bundles the dependencies for the functions, if they are imports of the function itself. This API has the characteristic that uses @nuxtjs/sanity
package, which is a wrapper of Sanity for Nuxt, and exposes a hook called useSanity()
which is already exposed on Nuxt APIs (not explicit require needed).
If my understanding is correct, then the issue is because Netlify can’t detect the dependency, and is not bundled with the function. But I want to see from your perspective if there is anything I’m missing that I should add for this to work.
Appreciate your help.