Can't Deploy Vanilla Svelte/Sveltekit

Hello All!

I have 5 Svelte projects deployed on Vercel and can’t figure this out. I couldn’t deploy my project so I created a vanilla Svelte/Sveltekit project with the vercel adaptor and it won’t deploy. I checked my projects that deploy and the svelte.config.js and package.json and everything else appear the same.

**Here’s the error I get on both projects. **

2025-08-28T12:13:43.236Z [error] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/.svelte-kit/vercel-tmp/index.js' imported from /opt/rust/nodejs.js
at finalizeResolution (node:internal/modules/esm/resolve:287:11)
at moduleResolve (node:internal/modules/esm/resolve:956:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1192:14)
at defaultResolve (node:internal/modules/esm/resolve:1235:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
at ModuleLoader.import (node:internal/modules/esm/loader:539:34)
at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:234:31) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/.svelte-kit/vercel-tmp/index.js'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

Here’s my project summary:

The project builds successfully locally and generates all required files, including the missing /var/task/.svelte-kit/vercel-tmp/index.js. The error suggests a deployment-time issue where Vercel cannot locate the generated files, despite them being present in the build output.

-Are there any known issues with SvelteKit v2.36.3 + adapter-vercel v5.10.2?
-Could this be a build cache issue on Vercel’s end?
-Are there specific Node.js 20.x compatibility issues?
-Should we try a different build configuration or output directory?

Project Details
Framework: SvelteKit v2.36.3
Adapter: @sveltejs/adapter-vercel v5.10.2
Node.js: 20.x (explicitly specified)
Build Tool: Vite v7.1.3
CSS: TailwindCSS v4.1.12

Original Issue
Troubleshooting Steps Completed

  1. Configuration Fixes
    Package.json: Fixed build script to use “build”: “vite build” (SvelteKit v2.x standard)
    Node.js Version: Added explicit “engines”: {“node”: “20.x”} specification
    Runtime Config: Removed explicit runtime config to let Vercel auto-detect
    Dependencies: Moved TailwindCSS packages to dependencies for deployment

  2. Build Verification
    Local Build: npm run build works perfectly
    File Generation: All required files are generated correctly
    Syntax Validation: Both vercel-tmp/index.js and output/server/index.js have valid Node.js syntax

  3. Directory Structure Verification
    Key Configuration Files
    package.json
    }
    svelte.config.js
    ;
    vercel.json
    }
    .gitignore
    ]

Build Output Verification
Build Command: npm run build executes successfully
Vercel Adapter: Reports “Using @sveltejs/adapter-vercel :check_mark: done”
File Sizes: All files are properly generated (not empty/corrupted)
Import Resolution: vercel-tmp/index.js correctly imports from ../output/server/index.js

Current Status
Local Build: Working perfectly
File Generation: All required files present
Configuration: Optimized for Vercel deployment
Dependencies: Latest stable versions
Fresh Vercel Project: Ready for deployment

LOCAL TESTING RESULTS:

  • Vercel CLI 46.0.5 runs successfully locally
  • Dev server starts on http://localhost:5174/ without errors
  • All dependencies and configurations work in local Vercel environment
  • The issue appears to be specific to Vercel’s production deployment, not the local setup
james@jamess-mbp geogrow-fresh % vercel dev --listen 3000
Vercel CLI 46.0.5
> Running Dev Command “npm run dev”

> geogrow-fresh@0.0.1 dev
> vite dev

Port 5173 is in use, trying another one...

  VITE v7.1.3  ready in 1362 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help

I haven’t been able to repro this issue. Do you have a minimal reproducible example I can use to dig into the error?

Same here. Try using the vercel cli and using vercel deploy and vercel - -prod that works for me. But as soon as it auto deploys via a git it breaks the project during runtime.

I haven’t been able to figure out how to fix it totally. I even did a fresh svelte 5 repo and deploy and in no time after adding a few packages and 1 page I’m getting runtime errors concerning the MODULE. Nothing complicated no monorepo nothing.

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module “/var/task/..%5C..%5C..%5Capps%5Cshopwave-tt%5C.svelte-kit%5Cvercel-tmp%5Cindex.js” must not include encoded “/” or “\” characters imported from /opt/rust/nodejs.js at finalizeResolution (node:internal/modules/esm/resolve:249:11) at moduleResolve (node:internal/modules/esm/resolve:956:10) at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1192:14) at defaultResolve (node:internal/modules/esm/resolve:1235:79) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12) at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25) at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38) at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38) at ModuleLoader.import (node:internal/modules/esm/loader:539:34) at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:234:31) { code: ‘ERR_INVALID_MODULE_SPECIFIER’ } Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

I’ve just tried updating my configs to see if it would work.

vite.config.js
import tailwindcss from ‘@tailwindcss/vite’;import { sveltekit } from ‘@sveltejs/kit/vite’;

import { defineConfig } from ‘vite’;

import path from ‘path’;

export default defineConfig({

plugins: \[tailwindcss(), sveltekit()\],

resolve: {

    alias: {

        $lib: path.resolve('./src/lib').replace(/\\\\/g, '/'),

        $components: path.resolve('./src/lib/components').replace(/\\\\/g, '/'),

        $assets: path.resolve('./src/lib/assets').replace(/\\\\/g, '/'),

        $stores: path.resolve('./src/lib/stores').replace(/\\\\/g, '/'),

        $utils: path.resolve('./src/lib/utils').replace(/\\\\/g, '/'),

        $routes: path.resolve('./src/routes').replace(/\\\\/g, '/'),

        $app: path.resolve('./src').replace(/\\\\/g, '/')

    }

},

build: {

    target: 'esnext',

    minify: true,

    rollupOptions: {

        output: {

            manualChunks: undefined

        }

    }

},

define: {

    'process.platform': JSON.stringify('win32')

}

});

svelte.config.js
import adapter from ‘@sveltejs/adapter-vercel’;

import { vitePreprocess } from ‘@sveltejs/vite-plugin-svelte’;

import path from ‘path’;

/** @type {import(‘@sveltejs/kit’).Config} */

const config = {

// Consult https://svelte.dev/docs/kit/integrations

// for more information about preprocessors

preprocess: vitePreprocess(),

kit: {

    adapter: adapter({

        external: \[\],

        split: false,

        files: {

            routes: path.resolve('./src/routes').replace(/\\\\/g, '/'),

            lib: path.resolve('./src/lib').replace(/\\\\/g, '/'),

            appTemplate: path.resolve('./src/app.html').replace(/\\\\/g, '/'),

            errorTemplate: path.resolve('./src/error.html').replace(/\\\\/g, '/'),

            hooks: path.resolve('./src/hooks').replace(/\\\\/g, '/'),

            serviceWorker: path.resolve('./src/service-worker').replace(/\\\\/g, '/'),

            params: path.resolve('./src/params').replace(/\\\\/g, '/'),

            assets: path.resolve('./static').replace(/\\\\/g, '/'),

        }

    })

}

};

export default config;

Still salt

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.