Hi! It's my first time trying to compile a Kotlin ...
# javascript
d
Hi! It's my first time trying to compile a Kotlin Js library (3rd party), and the build keeps on getting stuck at kotlinNpmInstall... I tried googling and saw that some set the npm registry or empty the cache, tried that, but still getting stuck... did anyone encounter this before?
p
Have you tried to run it as gradle task from the command line with additional logging? https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_logging I should help you find the actual problem..
d
Yes, I tried... I didn't get any error, it was just stuck... now I tried upgrading to yarn2 and I'm getting this:
Copy code
>                 Process 'Resolving NPM dependencies using yarn' returns 1
                  
                  Usage Error: The nearest package directory (.../tmp/fritz2-mvp/build/js) doesn't seem to be part of the project declared in .../tmp.
  
  - If the project directory is right, it might be that you forgot to list fritz2-mvp/build/js as a workspace.
  - If it isn't, it's likely because you have a yarn.lock or package.json file there, confusing the project root detection.
p
Wow, never seen this one.. How about this https://stackoverflow.com/a/64140079/600132 ? can you try that?
d
I saw that one... but I guess I missed one packages.json... now that I removed it, I got:
Process 'Resolving NPM dependencies using yarn' returns 1
Internal Error: Duplicate workspace name mvp: .../tmp/fritz2-mvp/build/js/packages/mvp conflicts with .../tmp/fritz2-mvp/build/js at ie.addWorkspace (/home/david/.yarn/releases/yarn-berry.cjs2352547) at async ie.setupWorkspaces (/home/david/.yarn/releases/yarn-berry.cjs2352236) at async Function.find (/home/david/.yarn/releases/yarn-berry.cjs2349034) at async Ye.execute (/home/david/.yarn/releases/yarn-berry.cjs2107804) at async Ye.validateAndExecute (/home/david/.yarn/releases/yarn-berry.cjs2659490) at async Y.run (/home/david/.yarn/releases/yarn-berry.cjs173854) at async ne.execute (/home/david/.yarn/releases/yarn-berry.cjs257216) at async ne.validateAndExecute (/home/david/.yarn/releases/yarn-berry.cjs2659490) at async Y.run (/home/david/.yarn/releases/yarn-berry.cjs173854) at async Y.runExit (/home/david/.yarn/releases/yarn-berry.cjs174021)
p
and if you go back to old yarn or npm?
and delete all the yarn.lock files again..
d
When I was at the old one, it just got stuck... each build I stopped after 10min.... and I tried clean a few times. But I guess I could try again...
p
is the project you’re trying to build somewhere publicly available?
d
https://github.com/hpehl/fritz2-mvp using ./gradlew publishToMavenLocal
It seems like yarn doesn't like this:
p
works just fine for me
Copy code
gradle publishToMavenLocal 
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :buildSrc:compileKotlin
The `kotlin-dsl` plugin applied to project ':buildSrc' enables experimental Kotlin compiler features. For more information see <https://docs.gradle.org/6.8/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin>

> Task :buildSrc:jar
:jar: No valid plugin descriptors were found in META-INF/gradle-plugins

BUILD SUCCESSFUL in 1m 39s
12 actionable tasks: 12 executed
d
Looks like something's wrong with my node/npm/yarn setup here...
~ 173004 $ node --version v14.15.4 ~ 175357 $ yarn --version 2.4.0 ~ 175403 $ npm --version 3.5.2
What to you have?
p
maybe, also try the
clean
before the build, like
gradlew clean publishToMavenLocal
15.3.0 node, no yarn, 7.0.14 npm
d
same error with clean...
wow... how did you install them? You're on linux? I used snaps...
And how can I disable yarn?
p
mac actually (so brew)
uninstall it I guess? 🙂
d
Maybe... I don't know node too much... but when you take something away from it, it might complain... but thanks! I'll try getting everything to those versions.
p
current node seems to be 15.6.0 (includes npm 7.4.0)
try to update your node, what OS do you use?
d
linux mint 18
p
so they say
Copy code
# Using Ubuntu
curl -sL <https://deb.nodesource.com/setup_15.x> | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL <https://deb.nodesource.com/setup_15.x> | bash -
apt-get install -y nodejs
d
Thanks! That did it for node and npm... now trying to get rid of yarn...
Now, I'm confused... I got rid of Yarn... I'm up to the right versions and I still get the error above:
             Process 'Resolving NPM dependencies using yarn' returns 1
              Internal Error: Duplicate workspace name mvp: .../tmp/fritz2-mvp/build/js/packages/mvp
It looks as if gradle is using it's own cached version or something...
I tried cleaning and erasing all the project's caches...
p
what gradle version do you have?
d
I just erased .yarnrc and .yarnrc.yaml... and I'm back to waiting for kotlinNpmInstall... 🤒
p
so if you run
yarn --version
in command line it does not work anymore?
d
$ yarn --version zsh: command not found: yarn
Now there's no mention of yarn, but stuck at kotlinNpmInstall
p
and how is you internet connection speed?
it’s 147MB of node modules in the end
d
94.57 mbps
And I don't see the node_modules folder in the build folder
When I had yarn, I saw it at a certain point, but it was giving me other errors...
p
you known, because of this

https://fettblog.eu/wp-content/uploads/2020/node-modules-meme.png

😅 2
but that should be sufficient for sure
d
Ok, this is really getting funny (after erasing my .npm folder):
Copy code
$ ./gradlew clean publishToMavenLocal

> Task :packageJson
Cannot find build/js/packages_imported/kotlin/1.4.20, rebuilding
Cannot find build/js/packages_imported/fritz2-core/0.8.0, rebuilding
Cannot find build/js/packages_imported/kotlinx-coroutines-core/1.4.1, rebuilding
Cannot find build/js/packages_imported/kotlinx-atomicfu/0.14.4, rebuilding
Cannot find build/js/packages_imported/kotlin-test-js-runner/1.4.20, rebuilding
Cannot find build/js/packages_imported/kotlin-test/1.4.20, rebuilding

> Task :kotlinNpmInstall FAILED
error Couldn't find package "dukat@0.5.8-rc.3" required by "mvp@0.1.0" on the "npm" registry.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':kotlinNpmInstall'.
>                 Process 'Resolving NPM dependencies using yarn' returns 1
                  
                  yarn install v1.22.4
  info No lockfile found.
  [1/4] Resolving packages...
  info Visit <https://yarnpkg.com/en/docs/cli/install> for documentation about this command.
p
don’t you have somewhere .npmrc file that rewrites the common npm repository URL?
here is the content of the
package.json
that is created by the build
Copy code
{
  ...
}
create empty folder somewhere, paste this content to
package.json
and then run in the same folder
npm install
maybe it will be in the npm not in the project itself
d
It has this: registry=http://registry.npmjs.org/
p
sorry the pasted file does not work..
go to the project, run
clean
task then run
packageJson
task and then go to
fritz2-mvp/build/js/packages/mvp/
there will be
pre-package.json
file
rename it to
package.json
and then run
npm install
in this very folder
d
I tried npm install there, and got: $ npm install npm ERR! code EAI_AGAIN npm ERR! syscall getaddrinfo npm ERR! errno EAI_AGAIN npm ERR! request to http://registry.npmjs.org/dukat failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org npm ERR! A complete log of this run can be found in: npm ERR! /home/david/.npm/_logs/2021-01-24T16_35_38_217Z-debug.log
p
seems like your DNS servers are off
d
That's getting closer to the problem...
p
what is in the actual log file?
d
47 verbose stack FetchError: request to http://registry.npmjs.org/dukat failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org 47 verbose stack at ClientRequest.<anonymous> (/usr/lib/node_modules/npm/node_modules/minipass-fetch/lib/index.js9714) 47 verbose stack at ClientRequest.emit (nodeevents379:20) 47 verbose stack at Socket.socketErrorListener (node http client494:9) 47 verbose stack at Socket.emit (nodeevents391:22) 47 verbose stack at emitErrorNT (nodeinternal/streams/destroy188:8) 47 verbose stack at emitErrorCloseNT (nodeinternal/streams/destroy153:3) 47 verbose stack at processTicksAndRejections (nodeinternal/process/task queues81:21)
p
so if you run
ping <http://registry.npmjs.org|registry.npmjs.org>
does it work?
d
.... nope it doesn't... it gives an unkown host... wow. But anything i can use instead?
Oh now it works.
p
well here is the issue
it might sound stupid 🙂 but have you tried to reboot the machine?
d
Yes...
That was one of the first things i tried
p
well it’s a connection issue for sure
d
It seems like the connection to the registry isnt stable, works on and off...
p
works fine for me, so it’s somewhere between you and the registry
d
There's no other registries?
p
can you try to change the DNS to 1.1.1.1 (cloudfare) or 8.8.8.8 (google) ?
you can setup your own (proxy) and maybe there are some paid ones..
d
Thanks alot for all the help! I'll give that a try.
p
GL, no problem 🙂, fingers crossed
j
At my work we have a corporate NPM proxy and I can’t NPM anything without VPNing
d
It worked today... 🤔, maybe yesterday the nameservers didn't get changed yet... but thanks again for all the help 🙂!
👍 1