PassTheMayo / minecraft-server-util

A Node.js library for Minecraft servers that can retrieve status, query, RCON, and send Votifier votes.
https://passthemayo.gitbook.io/minecraft-server-util/
MIT License
141 stars 24 forks source link

bug: cannot find module `tslib` in versions 5.1.2+ #62

Closed jojomatik closed 2 years ago

jojomatik commented 2 years ago

Describe the bug: I tried to update minecraft-server-util to the latest version, based on this pull request (https://github.com/jojomatik/blockcluster/pull/254) by @dependabot.

Unfortunately while trying to run my software I receive an error:

2021-12-19T19:54:03.286758200Z node:internal/modules/cjs/loader:936
2021-12-19T19:54:03.286814000Z   throw err;
2021-12-19T19:54:03.286818800Z   ^
2021-12-19T19:54:03.286821100Z 
2021-12-19T19:54:03.286822900Z Error: Cannot find module 'tslib'
2021-12-19T19:54:03.286824600Z Require stack:
2021-12-19T19:54:03.286826300Z - /usr/games/blockcluster/backend/node_modules/minecraft-server-util/dist/index.js
2021-12-19T19:54:03.286829000Z - /usr/games/blockcluster/backend/dist/backend/src/components/server.js
2021-12-19T19:54:03.286830700Z - /usr/games/blockcluster/backend/dist/backend/src/backend.js
[...]
2021-12-19T19:54:03.286847800Z     at Module.require (node:internal/modules/cjs/loader:1005:19) {
2021-12-19T19:54:03.286849500Z   code: 'MODULE_NOT_FOUND',
2021-12-19T19:54:03.286851100Z   requireStack: [
2021-12-19T19:54:03.286852600Z     '/usr/games/blockcluster/backend/node_modules/minecraft-server-util/dist/index.js',
2021-12-19T19:54:03.286854300Z     '/usr/games/blockcluster/backend/dist/backend/src/components/server.js',
2021-12-19T19:54:03.286856000Z     '/usr/games/blockcluster/backend/dist/backend/src/backend.js'
2021-12-19T19:54:03.286857600Z   ]
2021-12-19T19:54:03.286859200Z }

I've browsed the commits and assume that it has something to do with this commit https://github.com/PassTheMayo/minecraft-server-util/commit/afcf6a6dc6ec11c1254687ff547ad2fa83c5443b and the inclusion of ts-lib as a dev-dependency.

I therefore upgraded to version 5.1.1 instead (https://github.com/jojomatik/blockcluster/commit/16bf3d3f7f1fb153ea4cd850583a50c7d9c42dea) and it works perfectly fine.

It seems to me that ts-lib would also be required for my project in production use. Is it possible that it would need to be added as a normal dependency instead of a dev-dependency so that it is supplied with the library?

Code:

/**
 * Retrieves the current server info and returns it.
 *
 * @return a promise of the status response.
 */
async getServerInfo(): Promise<JavaStatusResponse> {
  return await mc
    .status("localhost", this.port, { timeout: 300 })
    .then((response) => {
      return response;
    })
    .catch((error) => {
      throw error;
    });
}

(Link to code in repository)

Expected behavior: Method call is handled without any errors as in version 5.1.1.

Additional context I've just upgraded to the latest working version (to version 5.1.1) of minecraft-server-util in my project blockcluster and it works great. Thanks a lot @PassTheMayo!

PassTheMayo commented 2 years ago

I just published version 5.1.4 which removes this dependency entirely. Let me know if the issue is resolved in this release.

jojomatik commented 2 years ago

Just pushed an upgrade to version 5.2.1 to the beta branch of blockcluster: https://github.com/jojomatik/blockcluster/commit/d55689c33e022aa0e8de288e47b1dacd0405308f

Works like a charm, great and fast work, thank you very much!