D
Deno

help

Compile to exe

JJonas2/10/2024
Every time I run my exe I get the following error, But when I start my code normally with node main.js it works without problems. This is my Code:
import Discord, { Guild } from "discord.js";
import inquirer from "inquirer";
import { discordChoose, getBotToken } from "../../../lib/discord/main.js";
import { getRole } from "../../../lib/helper.js";

export const bot = async () => {
const token = await getBotToken();
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMessages,
],
});

process.on("unhandledRejection", (error: any) => {
console.log(chalk.red("An error occurred:"));
if (error.message === "Used disallowed intents") {
console.log(
chalk.red(
"The bot needs the following intents to work:\n- MESSAGE CONTENT INTENT\n- SERVER MEMBERS INTENT"
)
);
} else {
console.log(chalk.red(error.message));
}
discordChoose();
return;
});

client
.login(token)
.then(() => {
choose(client);
})
.catch(() => {
console.log(chalk.red("Invalid token!"));
discordChoose();
return;
});
};
import Discord, { Guild } from "discord.js";
import inquirer from "inquirer";
import { discordChoose, getBotToken } from "../../../lib/discord/main.js";
import { getRole } from "../../../lib/helper.js";

export const bot = async () => {
const token = await getBotToken();
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildVoiceStates,
Discord.GatewayIntentBits.MessageContent,
Discord.GatewayIntentBits.GuildMessages,
],
});

process.on("unhandledRejection", (error: any) => {
console.log(chalk.red("An error occurred:"));
if (error.message === "Used disallowed intents") {
console.log(
chalk.red(
"The bot needs the following intents to work:\n- MESSAGE CONTENT INTENT\n- SERVER MEMBERS INTENT"
)
);
} else {
console.log(chalk.red(error.message));
}
discordChoose();
return;
});

client
.login(token)
.then(() => {
choose(client);
})
.catch(() => {
console.log(chalk.red("Invalid token!"));
discordChoose();
return;
});
};
This is my package.json:
{
"type": "module",
"scripts": {
"start": "tsc && node dist/main.js",
"build": "deno compile dist/main.js"
},
"license": "ISC",
"devDependencies": {
"@types/figlet": "^1.5.8",
"@types/gradient-string": "^1.1.5",
"@types/inquirer": "^9.0.7",
"@types/node": "^20.10.0",
"typescript": "^5.3.2"
},
"dependencies": {
"axios": "^1.6.5",
"chalk": "^5.3.0",
"discord.js": "^14.14.1",
"dotenv": "^16.4.1",
"figlet": "^1.7.0",
"inquirer": "^9.2.12",
"nanospinner": "^1.1.0",
}
}
{
"type": "module",
"scripts": {
"start": "tsc && node dist/main.js",
"build": "deno compile dist/main.js"
},
"license": "ISC",
"devDependencies": {
"@types/figlet": "^1.5.8",
"@types/gradient-string": "^1.1.5",
"@types/inquirer": "^9.0.7",
"@types/node": "^20.10.0",
"typescript": "^5.3.2"
},
"dependencies": {
"axios": "^1.6.5",
"chalk": "^5.3.0",
"discord.js": "^14.14.1",
"dotenv": "^16.4.1",
"figlet": "^1.7.0",
"inquirer": "^9.2.12",
"nanospinner": "^1.1.0",
}
}
No description
DAHDeno AI Helper2/10/2024
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, there are a few things I can point out that might help you resolve the issue. Firstly, it seems like you are trying to compile a TypeScript project that uses Node.js-specific modules (like discord.js) with Deno. Deno and Node.js have different runtime environments and standard libraries, so a project written for Node.js will not work out of the box with Deno. Deno does not use node_modules or package.json, and it has its own set of APIs and module resolution strategy. The deno compile command is used to compile Deno projects into standalone executables, and it expects Deno-compatible code. Since your code and dependencies are written for Node.js, you cannot directly compile them with Deno. If you want to create an executable from your Node.js project, you would need to use a tool that is designed for Node.js, such as pkg or nexe. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. If you are looking to work with Deno, you would need to rewrite your code to be compatible with Deno's APIs and module system.
ASAntonio Sampaio2/11/2024
are you using deno?
JJonas2/11/2024
i use node.js
Aakumaruь2/11/2024
check if it works fine with deno run
JJonas2/11/2024
no

Looking for more? Join the community!

Recommended Posts
What does this library "assert" does?Hi https://deno.land/std@0.215.0/assert/mod.ts What does it do in this example? https://docs.deno.coWhat does this library "assert" does?https://deno.land/std@0.215.0/assert/mod.ts What does it do in this example? https://docs.deno.com/rLooking for an alternative to deno_domHi I'm looking for an alternative library to https://deno.land/x/deno_dom@v0.1.45/deno-dom-wasm.ts PCompile to exeEvery time I run my exe I get the following error: But when I start my code normally with node maiRunning untrusted code, eval-styleI have a project that on occassion I want to be able to execute JS code that I can then quickly get Available disk spaceI'm writing an API which will potentially create a large temporary file. I thought it would useful Verify AWS SNS signature with PEM certificateHello, I'm trying to verify aws sns messages in deno given a signing cert (in pem format, RSA sha1) Headers for WebSocket clientI need to connect Deno (as a client) to a WebSocket server that requires custom headers on connectioDeno testing with local oak serverI'm trying to setup a simple oak application for a few tests. The test steps work as expected but I Anyone aware of a streaming multipart parser for Deno?I'd like to handle the parts of a multipart/form-data stream in a server as they arrive rather than Deno does not deliver all the information with the EventSourceIs there some configuration or do I have to iterate in some way so that the entire message is delivegoogleapis.deno.devWhere can I find support for that lib? Tried [here](https://github.com/lucacasonato/deno_googleapis