我有一个正在运行的不和谐机器人,但我想将其编译成一个
.exe
文件。怎么做?
我尝试使用 pkg
和 nexe
,但都没有正确完成。 Nexe 甚至没有开始给我一些奇怪的错误,在阅读文档和互联网上的一些讨论后我无法修复这些错误。
Error: https://github.com/nexe/nexe/releases/download/v3.3.3/windows-x64-14.8.0 is not available, create it using the --build flag
和Error: vcbuild.bat nosign release x64 exited with code: 1
。
pkg
工作得更好,我得到了 exe
文件,但它似乎不起作用:
我有这段代码,其中 bot 是我的不和谐客户端。
bot.on('ready', () =>
{
console.log(bot.guilds.cache.toJSON());
bot.guilds.cache.forEach((gui) =>
{
console.log(gui.id + ' ' + gui.name + ' ' + gui.memberCount);
});
console.log('Bot started!');
});
当我使用
node index.js
启动它时,它会提供一台服务器,但如果我执行创建的 exe
文件,则不会提供任何服务器,尽管机器人已上线。
我的package.json
看起来像这样:
{
"name": "sth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"pkg": {
"assets": [ "jsons/**/*", "config.json" ]
},
"bin": "index.js",
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.4.1"
}
}
我做错了什么?为什么机器人启动了,但似乎无法执行任何操作?我错过了什么?
我不知道您可以使用
.exe
文件代码,但您可以使用 .bat
文件并将其放在桌面上并创建快捷方式或将其放在 shell:startup
上,因为您会想要编写此内容
@echo off
node "js file path"
或加号