{"record":{"id":"d09da06955b967c4","repo":"sveltejs/kit","slug":"name-exported-from-file-is-invalid-all-e","errorCode":null,"errorMessage":"`${name}` exported from ${file} is invalid — all exports from this file must be remote functions","messagePattern":"`(.+?)` exported from (.+?) is invalid — all exports from this file must be remote functions","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/internal/server/remote-functions.js","lineNumber":20,"sourceCode":"\n/** @type {RemoteInternals['type'][]} */\nconst types = ['command', 'form', 'prerender', 'query', 'query_batch', 'query_live'];\n\n/**\n * @param {Record<string, any>} module\n * @param {string} file\n * @param {string} hash\n */\nexport function init_remote_functions(module, file, hash) {\n\tif (module.default) {\n\t\tthrow new Error(\n\t\t\t`Cannot export \\`default\\` from a remote module (${file}) — please use named exports instead`\n\t\t);\n\t}\n\n\tfor (const [name, fn] of Object.entries(module)) {\n\t\tif (!types.includes(fn?.__?.type)) {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`${name}\\` exported from ${file} is invalid — all exports from this file must be remote functions`\n\t\t\t);\n\t\t}\n\n\t\tfn.__.id = `${hash}/${name}`;\n\t\tfn.__.name = name;\n\t}\n}\n","sourceCodeStart":2,"sourceCodeEnd":29,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/internal/server/remote-functions.js#L2-L29","documentation":"Every export from a remote module must be a valid remote function (its `__` metadata type must be one of the known remote-function types). Any plain value, class, or arbitrary function export is rejected because SvelteKit needs to stamp each export with a stable id and name for RPC.","triggerScenarios":"Exporting a plain constant (`export const API_KEY = 'x'`), a helper function, or a class from a `.remote.ts` file; exporting something created by a function that forgot to wrap it in `query`/`command`/`form` etc.","commonSituations":"Sharing types/constants alongside remote functions in the same file; accidentally importing and re-exporting a non-remote helper; forgetting the `query(...)`/`command(...)` wrapper so the raw function lacks `__` metadata.","solutions":["Remove non-remote exports from the remote module and move them to a regular module.","Wrap every exported function in the appropriate remote primitive (`query`, `command`, `form`, etc.).","Check that the export is not undefined due to a bad import (the wrapper was never called)."],"exampleFix":"// before\nexport const LIMIT = 10;\nexport const getPosts = () => db.posts.all();\n// after\nexport const getPosts = query(() => db.posts.limit(10).all());","handlingStrategy":"validation","validationCode":"// every export must carry remote-function metadata\nfor (const [name, fn] of Object.entries(mod)) {\n  if (!fn?.__?.type) throw new Error(`${name} in remote module is not a remote function`);\n}","typeGuard":"const isRemoteFunction = (v) => typeof v === 'function' && v?.__ && typeof v.__.type === 'string';","tryCatchPattern":"try {\n  init(mod);\n} catch (e) {\n  if (String(e.message).includes('is invalid — all exports')) {\n    console.error('Move non-remote exports out of the remote module:', e.message);\n  } else throw e;\n}","preventionTips":["Wrap every exported function in query()/command()/form().","Keep constants/types/helpers in regular modules, not remote files.","Check for typos that make the wrapper's result undefined."],"tags":["remote-functions","module-exports","sveltekit"],"backgroundTag":"invalid-module-export","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}