tolgee / tolgee-cli

The Tolgee CLI
MIT License
16 stars 11 forks source link

Running commands to self-hosted instance seems to always fail #32

Closed nielsvermaut closed 1 year ago

nielsvermaut commented 1 year ago

Hi,

I've been trying to use the v1.0.0 version of the CLI but can't seem to get it to work. When I run the following commands I always seem to get exceptions for a dependency error.

I've installed the CLI via the npm today (16/02/2023 13:00GMT+2).

$ tolgee compare --project-id 4 --api-url https://translate.[redacted].com/ --api-key [redacted] translations

šŸ­āœ…     Analyzing code...
šŸ”“ An unexpected error occurred while running the command.
šŸ”“ Please report this to our issue tracker: https://github.com/tolgee/tolgee-cli/issues
TypeError: undici_1.Request is not a constructor
    at Requester.request (/usr/local/lib/node_modules/@tolgee/cli/dist/client/internal/requester.js:62:25)
    at Requester.requestJson (/usr/local/lib/node_modules/@tolgee/cli/dist/client/internal/requester.js:81:21)
    at ProjectClient.fetchAllKeys (/usr/local/lib/node_modules/@tolgee/cli/dist/client/project.js:16:14)
    at Command.compareHandler (/usr/local/lib/node_modules/@tolgee/cli/dist/commands/sync/compare.js:18:50)
    at async Command.parseAsync (/usr/local/lib/node_modules/@tolgee/cli/node_modules/commander/lib/command.js:935:5)
    at async run (/usr/local/lib/node_modules/@tolgee/cli/dist/index.js:136:9)
tolgee push --project-id 4 --api-url https://translate.[redacted].com/ --api-key [redacted] translations      
šŸ­āœ…     Reading files...
šŸ­šŸ”“     Deleting import...
šŸ”“ An unexpected error occurred while running the command.
šŸ”“ Please report this to our issue tracker: https://github.com/tolgee/tolgee-cli/issues
TypeError: undici_1.Request is not a constructor
    at Requester.request (/usr/local/lib/node_modules/@tolgee/cli/dist/client/internal/requester.js:62:25)
    at Requester.requestVoid (/usr/local/lib/node_modules/@tolgee/cli/dist/client/internal/requester.js:99:32)
    at ImportClient.deleteImport (/usr/local/lib/node_modules/@tolgee/cli/dist/client/import.js:44:30)
    at ImportClient.deleteImportIfExists (/usr/local/lib/node_modules/@tolgee/cli/dist/client/import.js:52:24)
    at prepareImport (/usr/local/lib/node_modules/@tolgee/cli/dist/commands/push.js:61:70)
    at Command.pushHandler (/usr/local/lib/node_modules/@tolgee/cli/dist/commands/push.js:106:26)
    at async Command.parseAsync (/usr/local/lib/node_modules/@tolgee/cli/node_modules/commander/lib/command.js:935:5)
    at async run (/usr/local/lib/node_modules/@tolgee/cli/dist/index.js:136:9)

My "translations/" folder contains these files: https://gist.github.com/nielsvermaut/183cc776a1143e4665851cb7ed2d91a3

What could I be doing wrong or is this an actual bug?

cyyynthia commented 1 year ago

It seems Undici (one of the dependencies) isn't exposing the Request object, which I suspect is due to an outdated version of NodeJS installed on your system.

Can you double check your Node version is 18 or greater? If it isn't, you'll need to update NodeJS using your system package manager, as the Tolgee CLI officially supports Node 18+ only.

nielsvermaut commented 1 year ago

Hi, I've checked my node version and confirmed that the installed node version is 19.

$ nvm exec 19.0 node -v
Running node v19.0.1 (npm v8.19.2)
v19.0.1
$ nvm exec 19.0 tolgee --api-url=REDACTED --api-key=REDACTED sync -p 4 translations/
Running node v19.0.1 (npm v8.19.2)
šŸ­āœ…     Analyzing code...
šŸ”“ An unexpected error occurred while running the command.
šŸ”“ Please report this to our issue tracker: https://github.com/tolgee/tolgee-cli/issues
TypeError: fetch failed
    at fetch (/usr/local/lib/node_modules/@tolgee/cli/node_modules/undici/index.js:113:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Requester.request (/usr/local/lib/node_modules/@tolgee/cli/dist/client/internal/requester.js:68:26)
    at async Command.syncHandler (/usr/local/lib/node_modules/@tolgee/cli/dist/commands/sync/sync.js:47:24)
    at async Command.parseAsync (/usr/local/lib/node_modules/@tolgee/cli/node_modules/commander/lib/command.js:935:5)
    at async run (/usr/local/lib/node_modules/@tolgee/cli/dist/index.js:136:9)

As a extra precautionary step, I've reinstalled the cli globally, but this also yielded the same result.

cyyynthia commented 1 year ago

The error is quite different this time: now, the error seems to indicate the fetch calls fails to reach the target server at all, indicating whatever URL its trying to reach is unreachable (network error).

Can you please try and run the command again with verbose logging enabled (--verbose), so the CLI will log more information about what's going on? It should log more information about the failing HTTP call for a better troubleshooting.

cyyynthia commented 1 year ago

Hi there, it's been a while since the last update on this issue, so I'll close it as stale.

If you're still experiencing issues with the CLI, feel free to comment on this issue or drop a message on the community Slack.