Skip to content

Cloudflare cannot find the devalue module #13627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timoanttila opened this issue Mar 22, 2025 · 5 comments
Closed

Cloudflare cannot find the devalue module #13627

timoanttila opened this issue Mar 22, 2025 · 5 comments

Comments

@timoanttila
Copy link

timoanttila commented Mar 22, 2025

Describe the bug

I was making changes to a SvelteKit project that had no problems until yesterday. I use Cloudflare for hosting. I got the error below from Cloudflare:

10:02:35.691 | ✨ Success! Uploaded 63 files (45 already uploaded) (1.94 sec)
-- | --
10:02:35.691 |  
10:02:36.270 | ✨ Upload complete!
10:02:40.882 | Success: Assets published!
10:02:41.774 | Error: Failed to publish your Function. Got error: Uncaught Error: No such module "server/devalue".   imported from "server/index.js"

My local repository contains node_modules/devalue, which is used in multiple files within node_modules/@sveltejs/kit/src. There is no issue when using yarn dev or npm run preview locally.

  "devDependencies": {
    "@sveltejs/adapter-cloudflare": "latest", // Same problem with ^6.0.0
    "@tailwindcss/postcss": "^4.0.15",
    "@tuspe/components": "^1.8.0",
    "@types/luxon": "^3.4.2",
    "eslint": "^9.23.0",
    "eslint-config-prettier": "^10.1.1",
    "eslint-plugin-svelte": "^3.3.3",
    "js-cookie": "^3.0.5",
    "postcss": "^8.5.3",
    "prettier": "^3.5.3",
    "tailwind-merge": "^3.0.2",
    "tailwindcss": "^4.0.15",
    "typescript": "^5.8.2"
  },
  "dependencies": {
    "@iconify/svelte": "^4.2.0",
    "@sveltejs/kit": "^2.20.2",
    "@sveltejs/vite-plugin-svelte": "^5.0.3",
    "@zerodevx/svelte-toast": "^0.9.6",
    "luxon": "^3.5.0",
    "svelte": "^5.25.2",
    "svelte-check": "^4.1.5",
    "svelte-preprocess": "^6.0.3",
    "vite": "^6.2.2"
  }

Reproduction

I have a normal SvelteKit installation plus this hooks.ts:

import type {Reroute} from '@sveltejs/kit'

export const reroute: Reroute = ({url}) => {
  const path = url.pathname,
  parts = path.split('/')
  parts.shift()

  if (parts[0] !== 'en') {
    // Example: ['en', 'de'].includes(parts[0])
    return path // No need to reroute
  }

  if (parts.length === 1) {
    return '/' // Redirect /en to /
  }

  // Define your mappings for specific routes
  const exactMappings: Record<string, string> = {
    '/en/news': '/uutiset',
    '/en/games': '/ottelut',
    '/en/games/stats': '/ottelut/tilastot'
  }

  if (exactMappings[path]) {
    return exactMappings[path] // Exact match, perform the reroute
  }

  // Define mappings for routes with a prefix
  const prefixMappings: Record<string, string> = {
    '/en/news': '/uutiset'
  }

  for (const englishPrefix in prefixMappings) {
    if (path.startsWith(englishPrefix)) {
      const finnishPrefix = prefixMappings[englishPrefix]
      const suffix = path.substring(englishPrefix.length)
      return `${finnishPrefix}${suffix}` // Reroute with the correct prefix and suffix
    }
  }
}

My svelte.config.js:

import adapter from '@sveltejs/adapter-cloudflare'
import {vitePreprocess} from '@sveltejs/vite-plugin-svelte'
import {sveltePreprocess} from 'svelte-preprocess'

/** @type {import('@sveltejs/kit').Config} */
const config = {
  compilerOptions: {
    enableSourcemap: false
  },
  preprocess: [vitePreprocess(), sveltePreprocess()],
  kit: {
    adapter: adapter()
  }
}

export default config

System Info

System:
    OS: macOS 15.3.2
    CPU: (8) arm64 Apple M1
    Memory: 70.53 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.9.0 - /usr/local/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.2 - /usr/local/bin/npm
    bun: 1.1.36 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.3.1
  npmPackages:
    @sveltejs/adapter-cloudflare: latest => 1.0.0-next.45 
    @sveltejs/kit: ^2.20.2 => 2.20.2 
    @sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3 
    svelte: ^5.25.2 => 5.25.2 
    vite: ^6.2.2 => 6.2.2

Severity

blocking an upgrade

@DeltaLaboratory
Copy link

DeltaLaboratory commented Mar 22, 2025

I also have this issue with clsx module, but this issue seems not limited to specific module but any module.

@llama-for3ver
Copy link

Same here, from a relatively newly generated sv project.

"devDependencies": {
        "@eslint/compat": "^1.2.5",
        "@eslint/js": "^9.18.0",
        "@playwright/test": "^1.49.1",
        "@sveltejs/adapter-auto": "^4.0.0",
        "@sveltejs/kit": "^2.16.0",
        "@sveltejs/vite-plugin-svelte": "^5.0.0",
        "@tailwindcss/vite": "^4.0.0",
        "@testing-library/jest-dom": "^6.6.3",
        "@testing-library/svelte": "^5.2.4",
        "daisyui": "^5.0.3",
        "eslint": "^9.18.0",
        "eslint-config-prettier": "^10.0.1",
        "eslint-plugin-svelte": "^3.0.0",
        "globals": "^16.0.0",
        "jsdom": "^26.0.0",
        "prettier": "^3.4.2",
        "prettier-plugin-svelte": "^3.3.3",
        "prettier-plugin-tailwindcss": "^0.6.11",
        "svelte": "^5.0.0",
        "svelte-check": "^4.0.0",
        "tailwindcss": "^4.0.0",
        "typescript": "^5.0.0",
        "typescript-eslint": "^8.20.0",
        "vite": "^6.0.0",
        "vitest": "^3.0.0"
    },
    "dependencies": {
        "@inlang/paraglide-sveltekit": "^0.15.5",
        "@lucide/svelte": "^0.483.0",
        "@supabase/ssr": "^0.6.1",
        "@sveltejs/adapter-cloudflare": "^6.0.0",
        "buffer": "^6.0.3",
        "svelte-jsoneditor": "^3.1.0"
    }

@sphfaar
Copy link

sphfaar commented Mar 22, 2025

I temporarily solved downgrading "@sveltejs/adapter-cloudflare" from "^6.0.0" to "^5.1.0" in a new project.

"devDependencies": {
	"@cloudflare/workers-types": "^4.20250320.0",
	"@eslint/compat": "^1.2.7",
	"@eslint/js": "^9.23.0",
	"@sveltejs/adapter-auto": "^5.0.0",
	"@sveltejs/adapter-cloudflare": "^5.1.0", // <--- was ^6.0.0
	"@sveltejs/kit": "^2.20.2",
	"@sveltejs/vite-plugin-svelte": "^5.0.3",
	"@tailwindcss/vite": "^4.0.15",
	"drizzle-kit": "^0.30.5",
	"eslint": "^9.23.0",
	"eslint-config-prettier": "^10.1.1",
	"eslint-plugin-svelte": "^3.3.3",
	"globals": "^16.0.0",
	"prettier": "^3.5.3",
	"prettier-plugin-svelte": "^3.3.3",
	"prettier-plugin-tailwindcss": "^0.6.11",
	"svelte": "^5.25.2",
	"svelte-check": "^4.1.5",
	"tailwindcss": "^4.0.15",
	"typescript": "^5.8.2",
	"typescript-eslint": "^8.27.0",
	"vite": "^6.2.2",
	"wrangler": "^4.3.0"
}

@Tihomir971
Copy link

Same problem.
`

13:18:20.176 | ✨ Success! Uploaded 22 files (88 already uploaded) (1.10 sec)
-- | --
13:18:20.176 |  
13:18:20.743 | ✨ Upload complete!
13:18:24.722 | Success: Assets published!
13:18:25.961 | Error: Failed to publish your Function. Got error: Uncaught Error: No such module "server/chunks/clsx".   imported from "server/chunks/index.js"

` I'm using shadcn-svelte util
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
	return twMerge(clsx(inputs));
}

@eltigerchino
Copy link
Member

Sorry about this. Please revert to @sveltejs/adapter-cloudflare v5.1.0 for now, or follow this workaround, or wait for v6.0.1 to be released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants