code-server: Cannot find module './lib/binding/napi-v3/argon2.node'[Bug]:

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Brave
  • Local OS: Android
  • Remote OS: Android (Termux, using proot-distro with the archlinux distro)
  • Remote Architecture: ARM64
  • code-server --version: 4.7.0 (can’t use command since it can’t run, but this is the version I downloaded)

Steps to Reproduce

  1. Use the install script to install code-server in the standalone method
  2. Try running code-server (like code-server --version)
  3. It fails.

Expected

code-server to run fine without any errors.

Actual

code-server crashes with the following error:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './lib/binding/napi-v3/argon2.node'
Require stack:
- /home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js'
  ]
}

Logs

Can’t run code-server at all, following error thrown:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './lib/binding/napi-v3/argon2.node'
Require stack:
- /home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js'
  ]
}

Screenshot/Video

Screenshot_20220916_135343

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

  • Albeit i’m using Termux, I run code-server in a proot-distro environment using the archlinux distro!
  • Installed nodejs-lts-gallium package and npm with pacman
  • Using npm directly doesn’t really work for me, the last time I’ve used it, no matter what I do I couldn’t upgrade code-server when a new release was released. (either saying it can’t find some cached files, or it doesn’t do anything and make me waste time)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

Hey, I know this is not directly connected to argon2 issue but since I bringed up termux I might as well follow up on it. Apparently termux has a user repository with it’s own code-server install script. (see here: code-server) Installing code-server was as easy as pkg install code-server after installing repo. Install script was created just a few days ago as well, figured I should give a heads up.

Yeah I would not expect the standalone arm64 GitHub release to work on Android. I believe we would need to compile specifically for Termux rather than generic Linux arm64. We should fix the install script trying to download a release that will not work and make it use npm install instead.

Thank you for sharing all that! One idea, which we’ve tried in the past is switching to @node-rs/argon2 (see here: https://github.com/coder/code-server/issues/4804#issuecomment-1030338395). We may investigate that again and see if using --force with the npm install works.

I think those links broke in the process of installation

Holy cow, that’s amazing insight. We’ve had troubles with Termux in the past and maybe this is the clue we’ve been missing. Thank you so much for trying and confirming!

@code-asher does this spark any ideas?

Sorry to bump the issue but I’ve had the same problem with op but mine was inside termux shell, not proot. Since links are a known issue I wanted to share my own insight to the problem. When you ignore the argon2 issue with yarn / npm and run install script it gives this output :

~ $ curl -fsSL https://code-server.dev/install.sh | sh
Linux 4.9.319-Phenix
Unsupported package manager.
Falling back to standalone installation.
Installing v4.8.0 of the arm64 release from GitHub.

+ Reusing ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mkdir -p ~/.local
+ mkdir -p ~/.local/lib ~/.local/bin
+ tar -C ~/.local/lib -xzf ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/obj.target/argon2.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/lib/binding/napi-v3/argon2.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/argon2.a: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/obj.target/argon2.a’: Permission denied
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/argon2.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/lib/binding/napi-v3/argon2.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/native-watchdog/build/Release/watchdog.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/native-watchdog/build/Release/obj.target/watchdog.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/spdlog/build/Release/spdlog.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/spdlog/build/Release/obj.target/spdlog.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/nothing.a: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/node-addon-api/nothing.a’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/watcher.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/obj.target/watcher.node’: Permission denied
tar: Exiting with failure status due to previous errors
~ $

But since I have root access why shouldn’t I use it when it’s just basic links right? This is the output when you fix linking issue :

~ $ node -v
v16.18.0
~ $ tsu
.../files/home # export HOME="/data/data/com.termux/files/home"   
~ # curl -fsSL https://code-server.dev/install.sh | sh
Linux 4.9.319-Phenix
Unsupported package manager.
Falling back to standalone installation.
Installing v4.8.0 of the arm64 release from GitHub.

+ mkdir -p ~/.cache/code-server
+ curl -#fL -o ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz.incomplete -C - https://github.com/coder/code-server/releases/download/v4.8.0/code-server-4.8.0-linux-arm64.tar.gz
######################################################################## 100.0%
+ mv ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz.incomplete ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mkdir -p ~/.local
+ mkdir -p ~/.local/lib ~/.local/bin
+ tar -C ~/.local/lib -xzf ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mv -f ~/.local/lib/code-server-4.8.0-linux-arm64 ~/.local/lib/code-server-4.8.0
+ ln -fs ~/.local/lib/code-server-4.8.0/bin/code-server ~/.local/bin/code-server

Standalone release has been installed into ~/.local/lib/code-server-4.8.0

Extend your path to use code-server:
  PATH="$HOME/.local/bin:$PATH"
Then run with:
  code-server
~ # echo $PATH
/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
~ # export PATH="$HOME/.local/bin:$PATH"
~ # echo $PATH
/data/data/com.termux/files/home/.local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
~ # code-server
/data/data/com.termux/files/home/.local/bin/code-server: 28: exec: /data/data/com.termux/files/home/.local/lib/code-server-4.8.0/lib/node: not found
~ # ln -fs /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/home/.local/lib/code-server-4.8.0/lib/
~ # code-server
node:internal/modules/cjs/loader:1239
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen failed: library "libstdc++.so.6" not found
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/data/data/com.termux/files/home/.local/lib/code-server-4.8.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  code: 'ERR_DLOPEN_FAILED'
}
~ #

As you can see node wasn’t recognized so I had to link it manually as well. I couldn’t go past this I’m afraid. Let me know if these help. Thanks.

Edit: Termux has mingw-w64-gcc-libs package that includes libstdc++ but installing it did not change anything whatsoever.

Ah yeah if you are using something like proot I believe the prebuild should work. Running directly on Termux should not work though as that would require specifically compiling for Termux.

I think our Termux docs mention proot but I wonder if our installer has some issues in that scenario like pulling the wrong prebuild. It would be worthwhile to verify the install script’s behavior in proot with a dry run to see what is trying to do.

There are some symlinks but I am not sure how they would break. It would make sense to see if we can reliably reproduce.

@jsjoeio I suppose code-server uses symlinks right? I think those links broke in the process of installation (I tried moving the extracted code-server from the comment above to ~/.local/lib and it gave back me argon2 error, rm-rf’ed the folder and re-extracted the tar with tar -xvf /path/to/code-server-tar.tar.gz in lib folder at .local and it worked fine)

It works when you download a tar.gz release for arm64, and run it direcrtly, executing code-server which is stored in the bin folder.

My specs are: termux the latest version (installed from github releases) proot’ed into manjaro-aarch64 node 18

The result: Screenshot_2022-09-23-02-10-51-464_com termux

But yes, the errors are the same when installed via the script.

@jsjoeio I understand. I’ll wait for the fix, you can take your time!

Thank you for the thorough explanation @RealEthanPlayzDev! I can empathize, this sounds frustrating. I am not sure myself or @code-asher have bandwidth to dive deep on this right now but I’ll make it high priority and we can look at this in the upcoming or next milestone.

@jsjoeio Nope, I don’t think it worked: (followed installation and rebuild steps, both failed) Screenshot_20220916-224719_Termux

I believe I’ve been starting to have issues with installating a standalone release ever since v4.5.1 when I reset my Termux data to redo it from scratch again, before that I used to be able to install v4.0.0, v4.0.2, v4.0.5