Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.component is not a function

I'm trying out sveltekit form actions, and it keeps on giving 500 Internal Error with the title in the console: node.component is not a function

src/routes/login/+page.server.js

import type { Actions } from '@sveltejs/kit';

export const actions: Actions = {
    default: async ({ request, cookies, url }) => {
        return { success: true }
    }
};

src/routes/+page.svelte

<form method="POST" action="/login">
    <div class="card-body"> 
        <button class="btn btn-primary w-100" type="submit">Login</button>
    </div>
</form>
like image 871
LeoDog896 Avatar asked Jul 15 '26 22:07

LeoDog896


2 Answers

You need to add a file src/routes/login/+page.svelte since without it the form won't be able to work. Do note that it needs to be that exact filename (+page.svelte or +layout.svelte respectively).

Or, if you have a +layout.server.ts, add an +layout.svelte with <slot/> in it

like image 108
LeoDog896 Avatar answered Jul 17 '26 19:07

LeoDog896


I'm adding this answer because I ran into this same problem, but couldn't find a missing +page.svelte for a form.

I had a nested +layout.server.ts that I was just using to serve data, but I didn't have a corresponding +layout.svelte.

I just put <slot /> in this new, nested +layout.svelte.

like image 43
ksm3939 Avatar answered Jul 17 '26 20:07

ksm3939