尝试运行yarn dev 来启动discord bot 时出现以下错误。我正在使用打字稿。我已经尝试过使用 nvm 来更新 Node js 版本。我什至尝试使用较低版本的node.js一直到16.20.2,但没有成功。我让 redis 服务器运行到我使用 redis-cli 的位置,它以 PONG 的形式返回。
node:events:493
throw er; // Unhandled 'error' event
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:236:11)
at defaultLoad (node:internal/modules/esm/load:128:3)
at nextLoad (node:internal/modules/esm/hooks:749:28)
at Z (file:///C:/Users/MSI/Documents/GitHub/steadfast-scrim/node_modules/tsx/dist/esm/index.mjs:13:1655)
at nextLoad (node:internal/modules/esm/hooks:749:28)
at Hooks.load (node:internal/modules/esm/hooks:382:26)
at handleMessage (node:internal/modules/esm/worker:199:24)
at checkForMessages (node:internal/modules/esm/worker:141:28)
at process.<anonymous> (node:internal/modules/esm/worker:160:5)
at process.emit (node:events:515:28) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Node.js v21.1.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
如果这对整个 github 存储库有帮助,请在这里
所以我修复错误的方法是将
"type": "module",
添加到 package.json
文件中。