Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: os.type is not a function #31

Closed
alandolsi opened this issue Jul 17, 2023 · 5 comments
Closed

Uncaught TypeError: os.type is not a function #31

alandolsi opened this issue Jul 17, 2023 · 5 comments

Comments

@alandolsi
Copy link

I become this error when i initialise the repository

Uncaught TypeError: os.type is not a function
at Translator.constructUserAgentString (deepl-node.js?v=e2e7fb1a:3446:33)
at new Translator (deepl-node.js?v=e2e7fb1a:3116:30)
at main.js:8:20
constructUserAgentString @ deepl-node.js?v=e2e7fb1a:3446
Translator @ deepl-node.js?v=e2e7fb1a:3116
(anonym) @ main.js:8

@JanEbbing
Copy link
Member

Hi, which version of NodeJS are you using? Are you using some kind of framework to build an application with (React Native, Ionic, etc)? It seems the os module of Node isn't available.

I will create a task anyway to make sure an exception in that function doesn't break the library.

@alandolsi
Copy link
Author

Hi,

I test it with node v18.16.1 (npm v9.5.1) and with node v16.20.0 (npm v8.19.4)
I am using vitejs.

thank you

@JanEbbing
Copy link
Member

Thanks, I can reproduce this and will look into it.

@JanEbbing
Copy link
Member

Hi @alandolsi .

  1. To fix the direct error you are seeing, you need to polyfill the os module as Vite does not. There are some people with similar problems and their solutions here, here and this is a module which does this.
  2. However, this is a NodeJS package and the above is a bandaid solution. Please read this answer why we don't support running in the frontend (I think this is the next problem you would run into, aside from likely leaking your API key in the frontend source code). You will need some backend that can make the DeepL API requests.

Please let me know if this doesn't solve your problem.

@alandolsi
Copy link
Author

@JanEbbing Thank you for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants