I am having an error when deploying a SvelteKit app that uses some Node.js packages in the server. I get this error in the logs:
The package “path” 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.
So, where do I have to use “platform: 'node”" in my project??
That error is from
esbuild and not something you’ll be able to do in Workers (and therefore Pages).
You will need to find a package that doesn’t use Node.js modules like
path for compatibility with Pages, or ones that use the
node: prefix for imports, and in which case you can use
nodejs_compat with a bunch of Node.js modules: Node.js compatibility · Cloudflare Workers docs
Which package(s) are you trying to use? We might be able to suggest some alternatives.
I am using the following npm packages:
mongoose, bcrypt, jsonwebtoken and
resend for emails.
mongoose, I was making requests to the DB with no problem until I added
bcrypt, which uses some node modules.
I’ve moved this website already to Vercel, but would prefer to have it in Cloudflare.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.