You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cloudflare uses its own JS runtime, so it is not possible to use Node builtins like fs or packages that specifically depend on Node like better-sqlite3. This is possible on, at least, Netlify.
Because IMO Cloudflare hasn't made this clear, a user might try to use them, correctly resulting in an error saying that some packages used are unavailable. However, this error is passed directly from esbuild, and reads like this as a result:
The package "util" 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.
This message reads as if it's emitted by SvelteKit or Vite and makes the user search for where to specify the platform: 'node', without realizing that it's a platform limitation. This reddit post is an example of a confused user:
I am building an app with SvelteKit and publishing it to Cloudflare Pages, but some packages I am using cannot access node native functions. […] This happened just after I added some server-side code, so that might be the reason, but Sveltekit supports that through Cloudflare workers, so I don't understand why. Help would be appreciated!
Describe the proposed solution
adapter-cloudflare should catch that the user is trying to use packages that are unavailable but are provided by Node, and replace esbuild's message with an explanation that they are unavailable on Cloudflare Workers. Perhaps something like:
The package "util" wasn't found on the file system but is built into node. Please note that Cloudflare does not run serverless functions in node and, as such, non-standard node builtins are unavailable when building for Cloudflare.
Alternatives considered
The explanation could be added to adapter-cloudflare's README instead.
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Describe the problem
Cloudflare uses its own JS runtime, so it is not possible to use Node builtins like
fs
or packages that specifically depend on Node likebetter-sqlite3
. This is possible on, at least, Netlify.Because IMO Cloudflare hasn't made this clear, a user might try to use them, correctly resulting in an error saying that some packages used are unavailable. However, this error is passed directly from esbuild, and reads like this as a result:
This message reads as if it's emitted by SvelteKit or Vite and makes the user search for where to specify the
platform: 'node'
, without realizing that it's a platform limitation. This reddit post is an example of a confused user:Describe the proposed solution
adapter-cloudflare should catch that the user is trying to use packages that are unavailable but are provided by Node, and replace esbuild's message with an explanation that they are unavailable on Cloudflare Workers. Perhaps something like:
Alternatives considered
The explanation could be added to adapter-cloudflare's README instead.
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: