簡體   English   中英

嘗試在 discord 機器人上運行 npm 啟動,但我不斷收到“節點:事件”錯誤。 使用節點 v16.13.1 時

[英]trying to run npm start on a discord bot but i keep getting a 'node:events' error. While using node v16.13.1

package.json

 {
  "name": "5ambot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "dev": "nodemon index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^13.5.0",
    "dotenv": "^10.0.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

當我運行 npm 啟動時,我在internal/modules/cjs/loader.js:892中遇到錯誤

錯誤

Error: Cannot find module 'node:events'
Require stack:
- DIR\node_modules\discord.js\src\client\BaseClient.js
- DIR\node_modules\discord.js\src\index.js
- DIR\index.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> (DIR\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: [
    'DIR\\node_modules\\discord.js\\src\\client\\BaseClient.js',
    'DIR\\node_modules\\discord.js\\src\\index.js',
    'DIR\\index.js'
  ]
}

我嘗試重新安裝包鎖:-rm -rf node_modules package-lock.json && npm install && npm start

沒用。 我沒有想法,每個人都說它是因為節點版本太低,我沒有看到其他解決方案。 請幫忙

嘗試

刪除 node_modules 運行

npm cache clean --force
npm install
npm run start

或嘗試紗線

yarn

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM