-
Notifications
You must be signed in to change notification settings - Fork 325
Closed
Description
Compiling a SvelteKit application that uses postgres.js for edge gives the following errors:
Error message
> Using @sveltejs/adapter-vercel
✘ [ERROR] Could not resolve "os"
node_modules/postgres/src/index.js:1:15:
1 │ import os from 'os'
╵ ~~~~
The package "os" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "fs"
node_modules/postgres/src/index.js:2:15:
2 │ import fs from 'fs'
╵ ~~~~
The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "node:crypto"
node_modules/ulidx/dist/esm/index.js:1:19:
1 │ import crypto from 'node:crypto';
╵ ~~~~~~~~~~~~~
The package "node:crypto" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "stream"
node_modules/postgres/src/large.js:1:19:
1 │ import Stream from 'stream'
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "net"
node_modules/postgres/src/connection.js:1:16:
1 │ import net from 'net'
╵ ~~~~~
The package "net" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "tls"
node_modules/postgres/src/connection.js:2:16:
2 │ import tls from 'tls'
╵ ~~~~~
The package "tls" wasn't found on the file system but is built into node. Are you trying to bundle
for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "crypto"
node_modules/postgres/src/connection.js:3:19:
3 │ import crypto from 'crypto'
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
✘ [ERROR] Could not resolve "stream"
node_modules/postgres/src/connection.js:4:19:
4 │ import Stream from 'stream'
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built into node. Are you trying to
bundle for node? You can use "platform: 'node'" to do that, which will remove this error.
error during build:
Error: Build failed with 8 errors:
node_modules/postgres/src/connection.js:1:16: ERROR: Could not resolve "net"
node_modules/postgres/src/connection.js:2:16: ERROR: Could not resolve "tls"
node_modules/postgres/src/connection.js:3:19: ERROR: Could not resolve "crypto"
node_modules/postgres/src/connection.js:4:19: ERROR: Could not resolve "stream"
node_modules/postgres/src/index.js:1:15: ERROR: Could not resolve "os"
...
at failureErrorWithLog (/home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:1636:15)
at /home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:1048:25
at /home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:993:52
at buildResponseToResult (/home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:1046:7)
at /home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:1075:16
at responseCallbacks.<computed> (/home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:697:9)
at handleIncomingPacket (/home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:752:9)
at Socket.readFromStdout (/home/hamza/code/firestorm/node_modules/esbuild/lib/main.js:673:7)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489:12)
It would be nice to be able to use postgres.js from edge functions.
Reproduction steps
Replace this runtime with edge.
Note: You'll need to add
runtime: 'nodejs18.xfor in this server route to suppress unrelated errorsimport type { Config } from '@sveltejs/adapter-vercel'; export const config: Config = { runtime: 'nodejs18.x' };
Metadata
Metadata
Assignees
Labels
No labels