我正在尝试开发一个机器人来表达不同意见。我安装了npm install discord.js --save
图书馆。但是导入的时候却报错。我该如何修复它?
命令:node .
internal/modules/cjs/loader.js:892
throw err;
^
Error: Cannot find module 'node:events'
Require stack:
- C:\Users\Gobs\Desktop\blog3\node_modules\discord.js\src\client\BaseClient.js
- C:\Users\Gobs\Desktop\blog3\node_modules\discord.js\src\index.js
- C:\Users\Gobs\Desktop\blog3\main.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (C:\Users\Gobs\Desktop\blog3\node_modules\discord.js\src\client\BaseClient.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\Gobs\\Desktop\\blog3\\node_modules\\discord.js\\src\\client\\BaseClient.js',
'C:\\Users\\Gobs\\Desktop\\blog3\\node_modules\\discord.js\\src\\index.js',
'C:\\Users\\Gobs\\Desktop\\blog3\\main.js'
]
}
JSON
{
...
"main": "main.js",
"scripts": {
},
"dependencies": {
"discord.js": "^13.2.0"
}
...
}
所需的 Node.js 版本不和谐.js是 v16.6。如果没有它,您可能会收到如下错误
- AbortController 未定义
- 意外的标记 '?'
- 找不到模块“节点:事件”
只需升级到 v16.6,这些错误就会得到修复。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)