Dynamic require of "tty" is not supported

Hey! I'm running a long-time project that we are deploying on Vercel. I wanted to move it over to Cloudflare workers, but I've had few challenges along the way. The most recent being this Dynamic require of "tty" is not supported when attempting to visit the site. The project uses Sveltekit that builds with Rollup. Is there any way to overcome this error? I don't know where to go from here. I've tried a few things with no luck. Any ideas?
1 Reply
Giraffe
GiraffeOP3d ago
Wrangler
{
"name": "*",
"account_id": "*",
"compatibility_date": "2025-01-14",
"compatibility_flags": ["nodejs_compat_v2"],
"build": {
"command": "bun run build"
},
"main": "./.cloudflare/worker.js",
"site": {
"bucket": "./.cloudflare/public"
},
"observability": {
"logs": {
"enabled": true
}
},
"placement": {
"mode": "smart"
},
"workers_dev": true
}
{
"name": "*",
"account_id": "*",
"compatibility_date": "2025-01-14",
"compatibility_flags": ["nodejs_compat_v2"],
"build": {
"command": "bun run build"
},
"main": "./.cloudflare/worker.js",
"site": {
"bucket": "./.cloudflare/public"
},
"observability": {
"logs": {
"enabled": true
}
},
"placement": {
"mode": "smart"
},
"workers_dev": true
}
Vite config
import { sveltekit } from '@sveltejs/kit/vite'
import type { UserConfig } from 'vite'

import commonjs from '@rollup/plugin-commonjs'
import rollupNodePolyfills from 'rollup-plugin-polyfill-node'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'

const production = process.env.NODE_ENV === 'production'

const config: UserConfig = {
optimizeDeps: {
include: [
'tslib'
],
esbuildOptions: {
define: {
global: 'globalThis',
},
}
},
build: {
commonjsOptions: {
include: [],
transformMixedEsModules: true,
requireReturnsDefault: 'auto'
},
rollupOptions: {
external: [],
output: {
exports: 'named',
manualChunks: undefined,
preserveModules: false,
sourcemap: false
},
plugins: [
nodeResolve({
browser: true
}),
rollupNodePolyfills(),
dynamicImportVars({
warnOnError: true
})
]
}
},
plugins: [
commonjs(),
sveltekit()
]
}

export default config
import { sveltekit } from '@sveltejs/kit/vite'
import type { UserConfig } from 'vite'

import commonjs from '@rollup/plugin-commonjs'
import rollupNodePolyfills from 'rollup-plugin-polyfill-node'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars'

const production = process.env.NODE_ENV === 'production'

const config: UserConfig = {
optimizeDeps: {
include: [
'tslib'
],
esbuildOptions: {
define: {
global: 'globalThis',
},
}
},
build: {
commonjsOptions: {
include: [],
transformMixedEsModules: true,
requireReturnsDefault: 'auto'
},
rollupOptions: {
external: [],
output: {
exports: 'named',
manualChunks: undefined,
preserveModules: false,
sourcemap: false
},
plugins: [
nodeResolve({
browser: true
}),
rollupNodePolyfills(),
dynamicImportVars({
warnOnError: true
})
]
}
},
plugins: [
commonjs(),
sveltekit()
]
}

export default config

Did you find this page helpful?