Skip to content

bittorrent-tracker --version fails due to package.json being imported via CommonJS require #554

@fixxi

Description

@fixxi

What version of this package are you using?
11.2.1

What operating system, Node.js, and npm version?
x86_64 Linux, Node.js 22.18.0, npm 11.6.0

What happened?
When I use the --version flag on the CLI I get the following error message:

file:///home/user/project/node_modules/bittorrent-tracker/bin/cmd.js:37
  console.log(require('../package.json').version)
          ^

ReferenceError: Cannot determine intended module format because both require() and top-level await are present. If the code is intended to be CommonJS, wrap await in an async function. If the code is intended to be an ES module, replace require() with import.
    at file:///home/user/project/node_modules/bittorrent-tracker/bin/cmd.js:37:11 {
  code: 'ERR_AMBIGUOUS_MODULE_SYNTAX'
}

What did you expect to happen?
That the program would output its version and exit normally.

Are you willing to submit a pull request to fix this bug?
Yes, I already have a fix in place. I will open a PR and edit this post shortly.
Edit: PR created #555

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions