node.component is not a function

Viewed 54

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>
2 Answers

You need to add a file src/routes/login/+page.svelte since without it the form won't be able to work.

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

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.

Related