英文:
Nodemon doesn't restart when changes are made on discord.js
问题
我正在使用discord.js在JavaScript上制作一个Discord机器人。我正在使用nodemon运行它,但当我对脚本进行更改时,脚本不会重新启动。请帮助我!
- index.js
const { Client, IntentsBitField } = require("discord.js");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});
client.on('ready', (c) => {
console.info(`✔ ${c.user.tag} is online.`);
});
client.on('messageCreate', (msg) => {
if (msg.content == 'Hello!')
msg.reply('Hi!');
});
client.login(
"my key"
);
命令是nodemon src/index.js
日志如下:
[nodemon] 2.0.22
[nodemon] 若要随时重新启动,请输入 `rs`
[nodemon] 正在监视路径:*.*
[nodemon] 正在监视扩展名:js,mjs,json
[nodemon] 正在启动 `node src/index.js`
✔ [RR] Military Bot#1578 已上线。
[nodemon] 由于更改而重新启动...
我尝试将命令从nodemon src/index.js
更改为nodemon -L src/index.js
,但没有奏效。然后我尝试从终端运行而不是从package.json
,但仍然没有效果。
英文:
I'm making a discord bot on JavaScript using discord.js. I am running it via nodemon, but when I'm making changes to the script, the script doesn't restart. Please help me!
- index.js
const { Client, IntentsBitField } = require("discord.js");
const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});
client.on('ready', (c) => {
console.info(`✔ ${c.user.tag} is online.`);
});
client.on('messageCreate', (msg) => {
if (msg.content == 'Hello!')
msg.reply('Hi!');
});
client.login(
"my key"
);
The command is nodemon src/index.js
The log is:
[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node src/index.js`
✔ [RR] Military Bot#1578 is online.
[nodemon] restarting due to changes...
I tried changing the command from nodemon src/index.js
to nodemon -L src/index.js
, but it didn't work. And then I tried running from the terminal instead of the package.json
but again, nothing.
答案1
得分: 0
尝试执行
npm -g uninstall nodemon
然后
npm -g install nodemon
我找到的解决办法。
英文:
Try executing
npm -g uninstall nodemon
then
npm -g install nodemon
The fixed that I found.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论