question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MPP JS client: Can't resolve 'text-encoding'

See original GitHub issue

Ktor Version

1.1.2

Ktor Engine Used(client or server and name)

Ktor client with default engine

JVM Version, Operating System and Relevant Context

JDK 1.8, Windows, Kotlin JS

Feedback

We are using the ktor client in a multiplatform project (android, iOS and web). Starting with version 1.1.0 the build of the JS client fails with the following message:

ERROR in ./kotlinx-io.js
Module not found: Error: Can't resolve 'text-encoding' in '<mypath>\kotlinmultiplatform\web\build\kotlin-js-min\main'
@ ./kotlinx-io.js 5309:21-45 5320:21-45
@ ./ktor-utils.js
@ ./web.js

If I manually add text-encoding as a npm-dependeny, it works.

If I list the npm dependency tree with the previous working ktor version 1.0.1 I get:

+-- kotlinx-io@0.1.4 -> <mypath>\kotlinmultiplatform\web\build\node_modules_imported\kotlinx-io extraneous
+-- kotlinx-io-js@0.1.1 -> <mypath>\kotlinmultiplatform\web\build\node_modules_imported\kotlinx-io-js
| +-- kotlin@1.3.10
| +-- kotlin-test@1.3.10
| | `-- kotlin@1.3.10 deduped
| +-- kotlinx-atomicfu@0.11.12 -> <mypath>\kotlinmultiplatform\web\build\node_modules_imported\kotlinx-atomicfu deduped
| `-- text-encoding@0.7.0

If I list the npm dependency tree with a ktor version >= 1.1.0 the kotlinx-io-js (and of course text-encoding) is missing

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
MrPowerGamerBRcommented, May 19, 2020

To fix this, I’ve added the following dependencies to my Gradle build:

		api(npm("text-encoding"))
		api(npm("bufferutil"))
		api(npm("utf-8-validate"))
		api(npm("abort-controller"))
		api(npm("fs"))

This fixed the issue for me!

2reactions
dhakehurstcommented, Nov 28, 2019

see https://github.com/Kotlin/kotlinx-io/issues/57 for my current work around

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ktor 1.5.2: Can't resolve 'node-fetch' on libs produced by ...
I'm using Ktor client with an MPP project. After upgrading to 1.5.2, I started having this error on a yarn project that is...
Read more >
npm cannot find module 'encoding' - Stack Overflow
js dev server running for the application, but I actually moved the location of the app into a new folder while the server...
Read more >
WhatsNew 1.3 | Ktor Framework
[JS client] Cannot change redirect policy by followRedirects=false ... MPP JS client: Can't resolve 'text-encoding'.
Read more >
text-encoding - npm
Start using text-encoding in your project by running `npm i text-encoding`. There are 665 other projects in the npm registry using ...
Read more >
MPP/JS code completion in HTML editor - Kotlin Discussions
However, the Intellij HMTL editor will mark ./client.js as cannot resolve file 'client.js' and code in <script> tags does not provide js code ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found