node

Hey, I'm trying to deploy my worker but I keep getting this 11 errors all similar to this one:

The package "string_decoder" wasn't found on the file system but is built into node.
Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.

and then when I try to add "node_compat = true" to wrangler.toml I get this error:

[WARNING] Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details.

[ERROR] The
nodejs_compat
compatibility flag cannot be used in conjunction with the legacy
--node-compat
flag. If you want to use the Workers runtime Node.js compatibility features, please remove the
--node-compat
argument from your CLI command or
node_compat = true
from your config file.

and then when I remove compatibility_flags = ["nodejs_compat"]
I get tons of errors and wranings like :

[WARNING] The package "node:worker_threads" wasn't found on the file system but is built into node.
[ERROR] Could not resolve "worker_threads"

node_modules/@discordjs/ws/dist/index.js:113:42:
113 │ var import_node_worker_threads2 = require("worker_threads");

All I'm trying to do is to run this code in "index.js"

const { ActivityType } = require("discord.js");

client.user.setPresence({
activities: [{
name: "Ready!",
}],
status: "online"
});

Please help
Was this page helpful?