code-server: [Bug]: Missing dependencies (minimist, yauzl, yazl)

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: Windows 10
  • Remote OS: Raspberry Pi 4
  • Remote Architecture: armhf
  • code-server --version:

Steps to Reproduce

  1. Install code-server by doing npm --global i code-server --unsafe-perm
  2. Startup code-server with no errors
  3. Send request to server, server gives error

Expected

No errors: webpage should display

Actual

Errors appear

Logs

Loading "minimist" failed
Error: Cannot find module 'minimist'
Require stack:
- /usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js
- /usr/local/lib/node_modules/code-server/out/node/util.js
- /usr/local/lib/node_modules/code-server/out/node/cli.js
- /usr/local/lib/node_modules/code-server/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.require._load (/usr/local/lib/node_modules/code-server/out/node/plugin.js:54:74)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at r (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:101)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1720)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at Object.errorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10423)
    at e.triggerErrorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11369)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11075
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1737)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at o._loadModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10432)
    at o._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:452)
    at o.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6144)
    at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1825)
    at h (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2554)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:75:26132)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:176:2108)
    at e._createAndEvalScript (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2598)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2237
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js',
    '/usr/local/lib/node_modules/code-server/out/node/util.js',
    '/usr/local/lib/node_modules/code-server/out/node/cli.js',
    '/usr/local/lib/node_modules/code-server/out/node/entry.js'
  ],
  phase: 'loading',
  moduleId: 'minimist',
  neededBy: [ 'vs/platform/environment/node/argv' ]
}
Here are the modules that depend on it:
[ 'vs/platform/environment/node/argv' ]
Loading "@microsoft/1ds-core-js" failed
Error: Cannot find module '@microsoft/1ds-core-js'
Require stack:
- /usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js
- /usr/local/lib/node_modules/code-server/out/node/util.js
- /usr/local/lib/node_modules/code-server/out/node/cli.js
- /usr/local/lib/node_modules/code-server/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.require._load (/usr/local/lib/node_modules/code-server/out/node/plugin.js:54:74)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at r (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:101)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1720)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at Object.errorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10423)
    at e.triggerErrorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11369)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11075
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1737)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at o._loadModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10432)
    at o._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:452)
    at o.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6144)
    at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1825)
    at h (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2554)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:135:9424)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:176:2108)
    at e._createAndEvalScript (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2598)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2237
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js',
    '/usr/local/lib/node_modules/code-server/out/node/util.js',
    '/usr/local/lib/node_modules/code-server/out/node/cli.js',
    '/usr/local/lib/node_modules/code-server/out/node/entry.js'
  ],
  phase: 'loading',
  moduleId: '@microsoft/1ds-core-js',
  neededBy: [ 'vs/server/node/telemetryClient' ]
}
Here are the modules that depend on it:
[ 'vs/server/node/telemetryClient' ]
Loading "yauzl" failed
Error: Cannot find module 'yauzl'
Require stack:
- /usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js
- /usr/local/lib/node_modules/code-server/out/node/util.js
- /usr/local/lib/node_modules/code-server/out/node/cli.js
- /usr/local/lib/node_modules/code-server/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.require._load (/usr/local/lib/node_modules/code-server/out/node/plugin.js:54:74)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at r (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:101)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1720)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at Object.errorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10423)
    at e.triggerErrorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11369)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11075
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1737)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at o._loadModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10432)
    at o._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:452)
    at o.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6144)
    at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1825)
    at h (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2554)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:140:86230)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:176:2108)
    at e._createAndEvalScript (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2598)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2237
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js',
    '/usr/local/lib/node_modules/code-server/out/node/util.js',
    '/usr/local/lib/node_modules/code-server/out/node/cli.js',
    '/usr/local/lib/node_modules/code-server/out/node/entry.js'
  ],
  phase: 'loading',
  moduleId: 'yauzl',
  neededBy: [ 'vs/base/node/zip' ]
}
Here are the modules that depend on it:
[ 'vs/base/node/zip' ]
Loading "yazl" failed
Error: Cannot find module 'yazl'
Require stack:
- /usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js
- /usr/local/lib/node_modules/code-server/out/node/util.js
- /usr/local/lib/node_modules/code-server/out/node/cli.js
- /usr/local/lib/node_modules/code-server/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.require._load (/usr/local/lib/node_modules/code-server/out/node/plugin.js:54:74)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at r (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:101)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1720)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at Object.errorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10423)
    at e.triggerErrorback (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11369)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11075
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:1737)
    at e.load (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:3:11005)
    at a (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10302)
    at o._loadModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:10432)
    at o._resolve (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:452)
    at o.defineModule (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:5:6144)
    at y (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:6:1825)
    at h (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2554)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:140:86230)
    at Object.<anonymous> (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/server/node/server.main.js:176:2108)
    at e._createAndEvalScript (/usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2598)
    at /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/loader.js:4:2237
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/lib/node_modules/code-server/lib/vscode/out/bootstrap-amd.js',
    '/usr/local/lib/node_modules/code-server/out/node/util.js',
    '/usr/local/lib/node_modules/code-server/out/node/cli.js',
    '/usr/local/lib/node_modules/code-server/out/node/entry.js'
  ],
  phase: 'loading',
  moduleId: 'yazl',
  neededBy: [ 'vs/base/node/zip' ]
}

Screenshot/Video

No response

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

There are other errors when not installing globally (such as a 404 error).

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 25 (12 by maintainers)

Most upvoted comments

A short term hack/workaround: after the global install, go to the node_modules/code-server/lib/vscode directory directly and issue an npm install --legacy-peer-deps.

After installing code-server(v4.11.0) on my Raspberry Pi 3(OS: Raspbian GNU/Linux 11) with npm(node v16.16.0): npm i -g code-server --unsafe-perm, i installed the missing libraries with the following commands:

npm i -g @microsoft/1ds-core-js minimist yauzl yazl spdlog xterm-headless
sudo apt install libsecret-1-dev

then changed into the node_modules/code-server/lib/vscode directory to run the command:

npm i --legacy-peer-deps

Eventually code-server works as expected.

I tried installing this three packages with npm globally and it seems the problem is solved sudo npm install -g @microsoft/1ds-core-js minimist yauzl i hope this will solve the problem

Ok able to reproduce on Ubuntu 22.04 on an ARM instance. Seems a problem with the underlying dependencies of lib/vscode, specifically xterm… Which I would have expected the shrinkwrap file to prevent…

ubuntu@ip-172-31-53-135:~/.nvm/versions/node/v16.17.0/lib/node_modules/code-server/lib/vscode$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: xterm-addon-search@0.10.0-beta.3
npm ERR! Found: xterm@4.20.0-beta.20
npm ERR! node_modules/xterm
npm ERR!   xterm@"4.20.0-beta.20" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer xterm@"^4.0.0" from xterm-addon-search@0.10.0-beta.3
npm ERR! node_modules/xterm-addon-search
npm ERR!   xterm-addon-search@"0.10.0-beta.3" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: xterm@4.19.0
npm ERR! node_modules/xterm
npm ERR!   peer xterm@"^4.0.0" from xterm-addon-search@0.10.0-beta.3
npm ERR!   node_modules/xterm-addon-search
npm ERR!     xterm-addon-search@"0.10.0-beta.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/ubuntu/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2022-09-02T17_25_45_732Z-debug-0.log

info? it still persist on latest version

I got an error installing spdlog:

C:\Users\Admin>npm i -g spdlog
npm ERR! code 1
npm ERR! path C:\Users\Admin\AppData\Roaming\npm\node_modules\spdlog
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR!   main.cc
npm ERR! C:\Users\Admin\AppData\Local\node-gyp\Cache\16.17.0\include\node\node.h(73,10): fatal  error C1083: Cannot open include file: 'v8.h': No such file or directory [C:\Users\Admin\AppData\Roaming\npm\node_modules\spdlog\build\spdlog.vcxproj]

It was resolved by deleting %LocalAppData%/node-gyp/Cache (https://github.com/nodejs/node-gyp/issues/2482#issuecomment-1004696012)

sudo yarn global code-server
yarn global v1.22.19
warning package.json: No license field
error Invalid subcommand. Try "add, bin, dir, ls, list, remove, upgrade, upgrade-interactive"
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
ravi@pi:~ $ sudo yarn global add code-server
yarn global v1.22.19
warning package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "code-server > @coder/logger@1.1.16" has unmet peer dependency "@google-cloud/logging@^4.5.2".
[4/4] Building fresh packages...
[2/2] ⠂ code-server
error /usr/local/share/.config/yarn/global/node_modules/code-server: Command failed.
Exit code: 1
Command: sh ./postinstall.sh
Arguments: 
Directory: /usr/local/share/.config/yarn/global/node_modules/code-server
Output:
Installing Code dependencies...
yarn.lock file not present, not running in development mode. use npm to install code-server!

Unfortunately I get error while installing code-server using yarn and it asks me to use npm to install it but when doing that I get

sudo npm install -g code-server
npm ERR! code 1
npm ERR! path /usr/lib/node_modules/code-server
npm ERR! command failed
npm ERR! command sh /tmp/postinstall-7802dc33.sh
npm ERR! Please pass --unsafe-perm to npm to install code-server
npm ERR! Otherwise the postinstall script does not have permissions to run
npm ERR! See https://docs.npmjs.com/misc/config#unsafe-perm
npm ERR! See https://stackoverflow.com/questions/49084929/npm-sudo-global-installation-unsafe-perm

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-09-03T02_25_12_938Z-debug-0.log

seems to be an error with the postinstall.sh script i can use the --unsafe-perm flag to install it properly but it ends up giving me the error of missing dependencies.

Relevant discussion for npm: https://github.com/npm/rfcs/pull/397, but doesn’t seem to go anywhere…

Brainstorming on next steps/fixes - happy to hear thoughts/other ideas:

  • After installing vscode, before doing the release, force an install of xterm@4.19.0 which will override the version brought by the yarn.lock from vscode (which is what eventually ends up in the release package we vend).
  • Edit the install script to issue a --legacy-peer-deps, which is going to revert to an older behavior which won’t validate these peer-deps.
  • Try to force upstream (vscode) to go back to xterm@4.19.0 - though likely wouldn’t work, as the next time they upgrade deps it’ll bump to the next beta version…

And either way, need to sanity check why logging for the nested commands is not being bubbled up to the user…

I suspect it’s an issue with how the combo npm + semver computes peerDependencies

Likely the semver carret plays differently with beta versions - i.e. doesn’t really consider 4.20.0-betaXX as a valid version above 4.19.0?