Unable to deploy in Pages despite `nodejs_compat` being set (SvelteKit and `pg`)

Hi, I have the following dependencies:
23:56:16.139 dependencies:
23:56:16.139 + @sveltejs/adapter-cloudflare 6.0.1
23:56:16.140 + @sveltejs/adapter-static 3.0.8
23:56:16.140 + @threlte/core 8.0.2
23:56:16.140 + @threlte/extras 9.1.3
23:56:16.140 + @types/pg 8.11.13
23:56:16.140 + dotenv 16.5.0
23:56:16.140 + katex 0.16.22
23:56:16.140 + marked 15.0.8
23:56:16.140 + marked-katex-extension 5.1.4
23:56:16.140 + pg 8.14.1
23:56:16.141 + pg-sql 1.1.0
23:56:16.141 + prismjs 1.30.0
23:56:16.141 + stylus 0.64.0
23:56:16.141 + svelte-markdown 0.4.1
23:56:16.141 + svelte-preprocess 6.0.3
23:56:16.141 + three 0.175.0
23:56:16.141
23:56:16.142 devDependencies:
23:56:16.142 + @sveltejs/adapter-auto 5.0.0
23:56:16.142 + @sveltejs/kit 2.20.7
23:56:16.142 + @sveltejs/vite-plugin-svelte 5.0.3
23:56:16.142 + @types/eslint 9.6.1
23:56:16.142 + @typescript-eslint/eslint-plugin 8.30.1
23:56:16.142 + @typescript-eslint/parser 8.30.1
23:56:16.142 + eslint 9.25.0
23:56:16.142 + eslint-config-prettier 10.1.2
23:56:16.143 + eslint-plugin-svelte 3.5.1
23:56:16.143 + globals 16.0.0
23:56:16.143 + prettier 3.5.3
23:56:16.144 + prettier-plugin-organize-imports 4.1.0
23:56:16.144 + prettier-plugin-svelte 3.3.3
23:56:16.144 + svelte 5.28.1
23:56:16.144 + svelte-check 4.1.6
23:56:16.145 + tslib 2.8.1
23:56:16.145 + typescript 5.8.3
23:56:16.145 + typescript-eslint 8.30.1
23:56:16.145 + vite 6.3.2
23:56:16.139 dependencies:
23:56:16.139 + @sveltejs/adapter-cloudflare 6.0.1
23:56:16.140 + @sveltejs/adapter-static 3.0.8
23:56:16.140 + @threlte/core 8.0.2
23:56:16.140 + @threlte/extras 9.1.3
23:56:16.140 + @types/pg 8.11.13
23:56:16.140 + dotenv 16.5.0
23:56:16.140 + katex 0.16.22
23:56:16.140 + marked 15.0.8
23:56:16.140 + marked-katex-extension 5.1.4
23:56:16.140 + pg 8.14.1
23:56:16.141 + pg-sql 1.1.0
23:56:16.141 + prismjs 1.30.0
23:56:16.141 + stylus 0.64.0
23:56:16.141 + svelte-markdown 0.4.1
23:56:16.141 + svelte-preprocess 6.0.3
23:56:16.141 + three 0.175.0
23:56:16.141
23:56:16.142 devDependencies:
23:56:16.142 + @sveltejs/adapter-auto 5.0.0
23:56:16.142 + @sveltejs/kit 2.20.7
23:56:16.142 + @sveltejs/vite-plugin-svelte 5.0.3
23:56:16.142 + @types/eslint 9.6.1
23:56:16.142 + @typescript-eslint/eslint-plugin 8.30.1
23:56:16.142 + @typescript-eslint/parser 8.30.1
23:56:16.142 + eslint 9.25.0
23:56:16.142 + eslint-config-prettier 10.1.2
23:56:16.143 + eslint-plugin-svelte 3.5.1
23:56:16.143 + globals 16.0.0
23:56:16.143 + prettier 3.5.3
23:56:16.144 + prettier-plugin-organize-imports 4.1.0
23:56:16.144 + prettier-plugin-svelte 3.3.3
23:56:16.144 + svelte 5.28.1
23:56:16.144 + svelte-check 4.1.6
23:56:16.145 + tslib 2.8.1
23:56:16.145 + typescript 5.8.3
23:56:16.145 + typescript-eslint 8.30.1
23:56:16.145 + vite 6.3.2
I have added the nodejs_compat flag via the dashboard, and similarly set a compatibility date of 2024-11-11 (this is the earliest date that's selectable that's after 2024-09-23). My NODE_VERSION is 20.18.1 and PNPM_VERSION is 10.8.1. I still get this error for many packages:
3 Replies
Ajay
AjayOP4d ago
02:23:22.597 ✘ [ERROR] Could not resolve "string_decoder"
02:23:22.597
02:23:22.597 ../../node_modules/.pnpm/[email protected]/node_modules/split2/index.js:20:34:
02:23:22.598 20 │ const { StringDecoder } = require('string_decoder')
02:23:22.598 ╵ ~~~~~~~~~~~~~~~~
02:23:22.598
02:23:22.598 The package "string_decoder" wasn't found on the file system but is built into node.
02:23:22.598 - Make sure to prefix the module name with "node:" or update your compatibility_date to 2024-09-23 or later.
02:23:22.597 ✘ [ERROR] Could not resolve "string_decoder"
02:23:22.597
02:23:22.597 ../../node_modules/.pnpm/[email protected]/node_modules/split2/index.js:20:34:
02:23:22.598 20 │ const { StringDecoder } = require('string_decoder')
02:23:22.598 ╵ ~~~~~~~~~~~~~~~~
02:23:22.598
02:23:22.598 The package "string_decoder" wasn't found on the file system but is built into node.
02:23:22.598 - Make sure to prefix the module name with "node:" or update your compatibility_date to 2024-09-23 or later.
I can't prefix the module name since it's in a library, unless I patch it. It should not be this difficult to deploy, so I'm wondering if I'm doing something completely wrong or if the versions are not compatible, though I could not find any documentation to support that.
Ajay
AjayOP4d ago
Full dump
Ajay
AjayOP4d ago
Update: I found a nodejs_compat_v2 flag, and I tried that. This should really be in the docs, I found it in some old Github issues but I didn't know it's still a thing. Those errors are now gone, but another one showed up. Will start a new post for that.

Did you find this page helpful?