Error [ERR_REQUIRE_ESM]: require() of ES Module(错误[ERR_REQUIRED_ESM]:ES模块的Required())
本文介绍了错误[ERR_REQUIRED_ESM]:ES模块的Required()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
V13,终端显示此错误: 错误:const ms=Required(‘parse-ms’)//npm i parse-ms ^ 错误[ERR_REQUIRED_ESM]:ES模块C的Required():UsersDELLOneDriveDesktopDiscord Bot 不支持C:UsersDELLOneDriveDesktopDiscord BotCommandsEconomyeg.js中的ode_module parse-msindex.js。
编码:
const db = require('quick.db') // npm i quick.db
const ms = require('parse-ms') // npm i parse-ms
module.exports = {
commands: ['beg'], // You Can Keep Any Name
description: 'Beg For Money', // Optional
callback: (message, args) => {
const user = message.member
const random = (min, max) => {
return Math.floor(Math.random() * (max - min) ) + min
}
const timeout = 60000 // 1 Min In MiliSecond
const amount = Math.floor(Math.random() * 900) + 100 // Min Is 100 And Max Is 1000(100+900)
let names = [ // Find More Names In Description
'Sir Cole Jerkin',
'Kim Kardashian',
'Logan Paul',
'Mr.Clean',
'Ryan Gosling',
'Ariana Grande',
'Default Jonesy',
'Cardi B',
'Dwight Shrute',
'Jesus',
'Taylor Swift',
'Beyoncé',
'Bill Clinton',
'Bob Ross',
'The Rock:',
'The Rock',
'Mike Hoochie',
'Doot Skelly',
'Ayylien',
'Spoopy Skelo'
]
const name = Math.floor(Math.random() * names.length) // To Get Random Name
let options = [
'Success',
'Failed'
]
let begged = random(0, parseInt(options.length))
let final = options[begged]
const begtime = db.fetch(`beg-time_${user.id}`) // Keep `beg-time_${message.guild.id}_${user.id}` If You Want Different In All Servers
if(begtime !== null && timeout - (Date.now() - begtime) > 0) {
const timeleft = ms(timeout - (Date.now() - begtime))
const embed = new MessageEmbed()
.setAuthor(`${user.user.username} Begged`, user.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor('RANDOM')
.setDescription(`
Already Begged, Beg Again In **${timeleft.seconds} Seconds**
Default CoolDown Is **1 Minutes**
`)
message.channel.send({embeds: [embed]})
} else {
if(final === 'Success') {
let gave = [
'Donated',
'Gave'
]
const give = Math.floor(Math.random() * gave.length)
db.add(`money_${user.id}`, amount)
const embed1 = new MessageEmbed()
.setAuthor(`${user.user.username} Begged`, user.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor('RANDOM')
.setDescription(`
**${names[name]}**: ${gave[give]} **$${amount}** To <@${user.user.id}>
`)
message.channel.send({embeds: [embed1]})
db.set(`beg-time_${user.id}`, Date.now())
} else if(final === 'Failed') {
let notgave = [
`I Don't Have Money`,
`I Am Also Poor`,
`I Already Gave Money To Last Beggar`,
`Stop Begging`,
`Go Away`
]
const notgive = Math.floor(Math.random() * notgave.length)
const embed2 = new MessageEmbed()
.setAuthor(`${user.user.username} Begged`, user.user.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor('RANDOM')
.setDescription(`
**${names[name]}**: ${notgave[notgive]}
`)
message.channel.send({embeds: [embed2]})
db.set(`beg-time_${user.id}`, Date.now())
}
}
}
}```
推荐答案
此包的3.0版现在仅支持使用使用不同语法进行导入的ES模块。
您可以将当前代码库切换为使用ESM,也可以选择将当前版本的parse-ms降级到V2.1
请参阅以下内容: https://github.com/sindresorhus/parse-ms/releases/tag/v3.0.0这篇关于错误[ERR_REQUIRED_ESM]:ES模块的Required()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:错误[ERR_REQUIRED_ESM]:ES模块的Required()


猜你喜欢
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01