ZumitoTeam / zumito-framework

Framework for creating a bot for discord
https://framework.zumito.dev
7 stars 1 forks source link

[🐛] Update Framework for Compatibility with Latest Node.js Version #38

Open WilliamAcosta1 opened 6 months ago

WilliamAcosta1 commented 6 months ago

The project is currently experiencing compatibility issues with the latest version of Node.js. When attempting to run the project using Node.js 20.x, the following error occurs:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/fernandomema/gitProjects/zumito-bot/src/Bot.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:141:22)
    at async nextLoad (node:internal/modules/esm/hooks:865:22)
    at async nextLoad (node:internal/modules/esm/hooks:865:22)
    at async Hooks.load (node:internal/modules/esm/hooks:448:20)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Steps to Reproduce

Clone the repository: git clone https://github.com/ZumitoTeam/zumito-framework.git Install dependencies: npm install Attempt to run the project with Node.js 20.x: npm run start

Expected Behavior

The project should run successfully on the latest version of Node.js without encountering any compatibility issues.

Actual Behavior

The project fails to run on Node.js 20.x, and the following error is displayed:

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/fernandomema/gitProjects/zumito-bot/src/Bot.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:141:22)
    at async nextLoad (node:internal/modules/esm/hooks:865:22)
    at async nextLoad (node:internal/modules/esm/hooks:865:22)
    at async Hooks.load (node:internal/modules/esm/hooks:448:20)
    at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Environment

Node.js version: 20.x Operating System: Windows, linux

Possible Solution

Change start script from

"start": "ts-node-esm src/Bot.ts",

to

"start": "node --loader ts-node/esm src/Bot.ts",