Build error (vercel)
amr3k opened this issue · 6 comments
Describe the bug
Vercel gives an error while building this project!
To Reproduce
- Connect Vercel with this repo
- Start building now
- The error will show up
Expected behaviour
A successful build
Additional context
Here's the build log:
TypeError: Cannot read property 'content' of undefined
12:24:08.959 | at get (file:///vercel/path0/.svelte-kit/output/server/entries/endpoints/_slug_/index.json.js:11:38)
12:24:08.959 | at render_endpoint (file:///vercel/path0/.svelte-kit/output/server/app.js:150:26)
12:24:08.959 | at resolve (file:///vercel/path0/.svelte-kit/output/server/app.js:1819:59)
12:24:08.959 | at async Object.handle (file:///vercel/path0/.svelte-kit/output/server/app.js:1935:20)
12:24:08.960 | at async respond (file:///vercel/path0/.svelte-kit/output/server/app.js:1770:22)
12:24:08.960 | at async fetch (file:///vercel/path0/.svelte-kit/output/server/app.js:1206:22)
12:24:08.960 | at async load (file:///vercel/path0/.svelte-kit/output/server/entries/pages/_slug_/index.svelte.js:150:15)
12:24:08.961 | at async load_node (file:///vercel/path0/.svelte-kit/output/server/app.js:1286:14)
12:24:08.961 | at async render_page (file:///vercel/path0/.svelte-kit/output/server/app.js:1651:20)
12:24:08.964 | TypeError: Cannot destructure property 'datePublished' of 'post' as it is undefined.
12:24:08.964 | at file:///vercel/path0/.svelte-kit/output/server/entries/pages/_slug_/index.svelte.js:80:11
12:24:08.964 | at Object.$render (file:///vercel/path0/.svelte-kit/output/server/chunks/index-13c0de55.js:90:18)
12:24:08.964 | at file:///vercel/path0/.svelte-kit/output/server/entries/pages/_slug_/index.svelte.js:172:54
12:24:08.964 | at Object.$render (file:///vercel/path0/.svelte-kit/output/server/chunks/index-13c0de55.js:90:18)
12:24:08.965 | at Object.default (file:///vercel/path0/.svelte-kit/output/server/app.js:61:96)
12:24:08.965 | at file:///vercel/path0/.svelte-kit/output/server/entries/pages/_slug_/__layout.svelte.js:4:42
12:24:08.965 | at Object.$render (file:///vercel/path0/.svelte-kit/output/server/chunks/index-13c0de55.js:90:18)
12:24:08.965 | at Object.default (file:///vercel/path0/.svelte-kit/output/server/app.js:55:111)
12:24:08.965 | at file:///vercel/path0/.svelte-kit/output/server/entries/pages/__layout.svelte.js:176:82
12:24:08.965 | at Object.$render (file:///vercel/path0/.svelte-kit/output/server/chunks/index-13c0de55.js:90:18)
12:24:08.967 | > 500 /undefined (linked from /)
12:24:08.968 | at file:///vercel/path0/node_modules/@sveltejs/kit/dist/chunks/index5.js:408:11
12:24:08.968 | at visit (file:///vercel/path0/node_modules/@sveltejs/kit/dist/chunks/index5.js:585:4)
12:24:08.968 | at processTicksAndRejections (internal/process/task_queues.js:95:5)
12:24:09.009 | error Command failed with exit code 1.
12:24:09.009
Hi Amr, thanks for reaching out. Sorry to see this isn't working for you. Just wanted to check you have replaced the static adapter with the Vercel one before deploying (I should add this to the README as a step)?
Sorry for the late reply :(
I added vercel adapter but got another error while building!
Generating manifest.json
--
19:48:34.403 | > Cannot find module '@sveltejs/app-utils/renderer'
19:48:34.403 | Require stack:
19:48:34.403 | - /vercel/path0/node_modules/@sveltejs/adapter-vercel/index.js
19:48:34.403 | Require stack:
19:48:34.404 | - /vercel/path0/node_modules/@sveltejs/adapter-vercel/index.js
19:48:34.404 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
19:48:34.404 | at Function.Module._load (internal/modules/cjs/loader.js:746:27)
19:48:34.404 | at Module.require (internal/modules/cjs/loader.js:974:19)
19:48:34.404 | at require (internal/modules/cjs/helpers.js:93:18)
19:48:34.404 | at Object.<anonymous> (/vercel/path0/node_modules/@sveltejs/adapter-vercel/index.js:7:16)
19:48:34.404 | at Module._compile (internal/modules/cjs/loader.js:1085:14)
19:48:34.405 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
19:48:34.405 | at Module.load (internal/modules/cjs/loader.js:950:32)
19:48:34.405 | at Function.Module._load (internal/modules/cjs/loader.js:790:12)
19:48:34.405 | at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
19:48:34.416 | error Command failed with exit code 1.
aha, at least we're making progress 😀.
I should have said you need to get the @next version of the adapter so if you're using pnpm:
pnpm add -D @sveltejs/adapter-vercel@next
hope that helps.
Thanks for the hint, the build went successfully ✌🏽
Which makes me ask why it didn't in the first time? why adding @next
solved it? is it the adapter problem, pnpm's or my lack of knowledge ?
Now we're clearly making progress, but now the webapp has a runtime error when visiting the homepage.
2022-02-16T14:16:38.643Z 556050fe-ea0f-49e7-bf62-de5d1fb5b5a2 ERROR Error: ENOENT: no such file or directory, scandir '/var/task/src/content/blog'
at Object.readdirSync (fs.js:1047:3)
at getPostsContent (/var/task/index.js:57961:45)
at get (/var/task/index.js:58024:24)
at load_shadow_data (/var/task/index.js:59577:28)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async load_node (/var/task/index.js:59341:28)
at async respond$1 (/var/task/index.js:59742:22)
at async render_page (/var/task/index.js:59872:20)
at async resolve (/var/task/index.js:60059:105)
at async Object.handle (/var/task/index.js:60173:20)
Sorry this dropped off my radar... did you get it working? There have been a couple of breaking changes in SvelteKit so it might just need updating
No problem, I rewrote the whole thing and used vite's glob import while using vercel adapter.