coder / code-server

VS Code in the browser
https://coder.com
MIT License
68.2k stars 5.6k forks source link

update npm installation docs with node requirements #2745

Closed mrfoxie closed 3 years ago

mrfoxie commented 3 years ago

I tried to install on termux using falling commands

pkg install nano yarn
yarn global add code-server

after then when I execute the command code-server or code-server --auth none and then I open url in chrome browser I get this error Screenshot_20210219_202138

this is the log of termux while running code-server Screenshot_2021_0219_202202

jsjoeio commented 3 years ago

Hmm...I wish I had an Android device to try and reproduce this.

Usually when you see this error, it means VSCode isn't done building. I see the "error VS Code exited unexpectedly with code 0". But since you already installed code-server with yarn, it should be finished 🤔

I wonder if that failed in some way. Maybe you can check the logs from after running yarn global add code-server

jsjoeio commented 3 years ago

There might be some helpful info here: https://stackoverflow.com/questions/55834349/what-is-the-path-to-yarn-error-log-files

Playit3110 commented 3 years ago

I tried to install it code-server over codeserver.dev/install.sh and noticed a lot of old or broken dependencies. I tried to run it as well and got a simular result. The only difference is my remote OS. It is a Raspberry Pi 4 4GB

jsjoeio commented 3 years ago

noticed a lot of old or broken dependencies

Well that's no good!

Can you try following these steps and let me know if the result is the same?

Playit3110 commented 3 years ago

Im not quiet sure which steps i should follow. Could you link to the issue or the comment here?

jsjoeio commented 3 years ago

Sorry looks like the link didn't get added! Updated the comment

Playit3110 commented 3 years ago

I already tried that too but i got the error global is not a file when i executed yarn global ...

jsjoeio commented 3 years ago

Hmm..strange. Can you please post the logs or a screenshot so I can see if I can reproduce your error?

Playit3110 commented 3 years ago

Here is the process:

Last login: Tue Mar  2 01:04:12 2021 from 192.168.2.xxx
pi@server:~ $ sudo apt update && apt upgrade
Get:1 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Hit:3 https://deb.nodesource.com/node_14.x buster InRelease
Fetched 15.0 kB in 1s (11.8 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
pi@server:~ $ sudo apt install build-essential python git nodejs yarn
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'cmdtest' instead of 'yarn'
build-essential is already the newest version (12.6).
git is already the newest version (1:2.20.1-2+deb10u3).
python is already the newest version (2.7.16-1).
nodejs is already the newest version (14.16.0-1nodesource1).
The following additional packages will be installed:
  libyaml-0-2 python-cliapp python-markdown python-pygments
  python-ttystatus python-yaml
Suggested packages:
  python-markdown-doc python-pygments-doc ttf-bitstream-vera
The following NEW packages will be installed:
  cmdtest libyaml-0-2 python-cliapp python-markdown
  python-pygments python-ttystatus python-yaml
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 892 kB of archives.
After this operation, 4,565 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf libyaml-0-2 armhf 0.2.1-1 [38.8 kB]
Get:2 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf python-yaml armhf 3.13-2 [118 kB]
Get:3 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf python-cliapp all 1.20180812.1-2 [42.2 kB]
Get:4 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf python-ttystatus all 0.38-2 [15.4 kB]
Get:5 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf python-markdown all 3.0.1-3 [60.6 kB]
Get:6 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf cmdtest all 0.32-3 [21.9 kB]
Get:7 http://ftp.agdsn.de/pub/mirrors/raspbian/raspbian buster/main armhf python-pygments all 2.3.1+dfsg-1 [596 kB]
Fetched 892 kB in 2s (405 kB/s)
Selecting previously unselected package libyaml-0-2:armhf.
(Reading database ... 111866 files and directories currently installed.)
Preparing to unpack .../0-libyaml-0-2_0.2.1-1_armhf.deb ...
Unpacking libyaml-0-2:armhf (0.2.1-1) ...
Selecting previously unselected package python-yaml.
Preparing to unpack .../1-python-yaml_3.13-2_armhf.deb ...
Unpacking python-yaml (3.13-2) ...
Selecting previously unselected package python-cliapp.
Preparing to unpack .../2-python-cliapp_1.20180812.1-2_all.deb ...
Unpacking python-cliapp (1.20180812.1-2) ...
Selecting previously unselected package python-ttystatus.
Preparing to unpack .../3-python-ttystatus_0.38-2_all.deb ...
Unpacking python-ttystatus (0.38-2) ...
Selecting previously unselected package python-markdown.
Preparing to unpack .../4-python-markdown_3.0.1-3_all.deb ...
Unpacking python-markdown (3.0.1-3) ...
Selecting previously unselected package cmdtest.
Preparing to unpack .../5-cmdtest_0.32-3_all.deb ...
Unpacking cmdtest (0.32-3) ...
Selecting previously unselected package python-pygments.
Preparing to unpack .../6-python-pygments_2.3.1+dfsg-1_all.deb ...
Unpacking python-pygments (2.3.1+dfsg-1) ...
Setting up libyaml-0-2:armhf (0.2.1-1) ...
Setting up python-ttystatus (0.38-2) ...
Setting up python-markdown (3.0.1-3) ...
Setting up python-pygments (2.3.1+dfsg-1) ...
Setting up python-yaml (3.13-2) ...
Setting up python-cliapp (1.20180812.1-2) ...
Setting up cmdtest (0.32-3) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10+rpi1) ...
pi@server:~ $ yarn global add code-server
00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'global'
pi@server:~ $

If you need a log, you have to help me where it is saved, because i have no idea

jsjoeio commented 3 years ago

Okay these might be dumb questions but bear with me.

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

  1. Does apt upgrade need to be run with sudo?

Note, selecting 'cmdtest' instead of 'yarn'

  1. Could that be an issue? Guessing it's using cmdtest which doesn't have a global command?

I found this potential fix that might work? (source):

sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
Playit3110 commented 3 years ago

Wow thanks a lot. Till now no error

jsjoeio commented 3 years ago

Sure thing! If it ends up working, feel free to close this issue!

Playit3110 commented 3 years ago

Sadly it still breaks when i try to log in. :(

500

VS Code failed to load. exited unexpectedly with code 0

Where can i see the logs of code-server

jsjoeio commented 3 years ago

Dang it! We were too optimistic too soon. Run code-server like so:

code-server --log debug

More info here in the docs.

Playit3110 commented 3 years ago

Here the console:

Last login: Tue Mar  2 17:19:07 2021 from xxx.xxx.xxx.xxx
pi@server:~ $ code-server --log debug
-bash: code-server: command not found
pi@server:~ $ ~/.yarn/bin/code-server --log debug
[2021-03-02T17:20:01.051Z] info  code-server 3.9.0 fc6d123da59a4e5a675ac8e080f66e032ba01a1b
[2021-03-02T17:20:01.054Z] info  Using user-data-dir ~/.local/share/code-server
[2021-03-02T17:20:01.124Z] info  Using config file ~/.config/code-server/config.yaml
[2021-03-02T17:20:01.124Z] info  HTTP server listening on http://0.0.0.0:8080
[2021-03-02T17:20:01.125Z] info    - Authentication is enabled
[2021-03-02T17:20:01.125Z] info      - Using password from ~/.config/code-server/config.yaml
[2021-03-02T17:20:01.125Z] info    - Using certificate for HTTPS: ~/.local/share/code-server/localhost.crt
[2021-03-02T17:20:46.242Z] debug redirecting from / to ./login
[2021-03-02T17:20:55.218Z] debug no valid cookie doman {"host":"192.168.2.110"}
[2021-03-02T17:20:55.222Z] debug redirecting from /login to ./
[2021-03-02T17:20:55.389Z] debug forking vs code...
[2021-03-02T17:20:56.338Z] error VS Code exited unexpectedly with code 0
^C[2021-03-02T17:21:24.551Z] debug child:20982 disposing {"code":"SIGINT"}
pi@server:~ $

Still no success

jsjoeio commented 3 years ago

Those logs aren't very helpful. They don't tell us too much :(

If VS Code is exiting, then I have to guess that there's a missing dependency or something. Honestly, we should have something like a doctor command which checks for all the dependencies needed to run code-server.

Hmm...a few things:

That might help us get to the bottom of this

code-asher commented 3 years ago

In addition, here's a list of required dependencies to build with yarn: https://github.com/cdr/code-server/blob/v3.9.0/docs/npm.md#npm-install-requirements

It might help to to re-install VS Code Node modules and post the log if there are any failures. Maybe something like:

$ cd $(yarn global dir)/node_modules/code-server/lib/vscode
$ yarn --check-files
Playit3110 commented 3 years ago

Here is the install process of the libaries:

Last login: Tue Mar  2 18:27:32 2021 from 192.168.2.xxx
pi@server:~ $ sudo apt-get install build-essential pkg-config libx11-dev libxkbfile-dev libsecret-1-dev python3
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.6).
libsecret-1-dev is already the newest version (0.18.7-1).
libx11-dev is already the newest version (2:1.6.7-1+deb10u1).
libxkbfile-dev is already the newest version (1:1.0.9-2).
pkg-config is already the newest version (0.29-6).
python3 is already the newest version (3.7.3-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@server:~ $ npm config set python python3
pi@server:~ $

And here are the dependencies which show my first problem, where a lot of them are old or deprecated or moved

Last login: Tue Mar  2 18:29:47 2021 from 192.168.2.xxx
pi@server:~ $ cd $(yarn global dir)/node_modules/code-server/lib/vscode
pi@server:~/.config/yarn/global/node_modules/code-server/lib/vscode $ yarn --check-files
yarn install v1.22.5
warning ../../../../package.json: No license field
info No lockfile found.
[1/4] Resolving packages...
warning chokidar > fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
warning @types/applicationinsights@0.20.0: This is a stub types definition for applicationinsights (https://github.com/Microsoft/ApplicationInsights-node.js). applicationinsights provides its own type definitions, so you don't need @types/applicationinsights installed!
warning @types/chokidar@2.1.3: This is a stub types definition. chokidar provides its own type definitions, so you do not need this installed.
warning @types/keytar@4.4.2: This is a stub types definition. keytar provides its own type definitions, so you do not need this installed.
warning cson-parser > coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
warning gulp > glob-watcher > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
warning gulp > glob-watcher > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
warning gulp > glob-watcher > chokidar > braces > snapdragon > source-map-resolve > resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
warning gulp > glob-watcher > chokidar > braces > snapdragon > source-map-resolve > urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
warning gulp-azure-storage > azure-storage > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning gulp-azure-storage > azure-storage > request > har-validator@5.1.5: this library is no longer supported
warning gulp-cssnano > cssnano > postcss-merge-rules > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning gulp-cssnano > cssnano > autoprefixer > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning gulp-cssnano > cssnano > postcss-merge-rules > caniuse-api > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning gulp-remote-retry-src > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning jsdom-no-contextify > request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
warning mocha > mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
warning mocha > glob > minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning mocha > to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead.
warning mocha > jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
warning mocha > jade > mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
warning opn@6.0.0: The package has been renamed to `open`
warning sinon > samsam@1.1.2: This package has been deprecated in favour of @sinonjs/samsam
warning sinon > formatio@1.1.1: This package is unmaintained. Use @sinonjs/formatio instead
warning sinon > formatio > samsam@1.1.3: This package has been deprecated in favour of @sinonjs/samsam
warning vsce > cheerio > cheerio-select-tmp@0.1.1: Use cheerio-select instead
warning webpack > watchpack > watchpack-chokidar2 > chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[2/4] Fetching packages...
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
info vscode-windows-ca-certs@0.2.0: The platform "linux" is incompatible with this module.
info "vscode-windows-ca-certs@0.2.0" is an optional dependency and failed compatibility check. Excluding it from installation.info vscode-windows-registry@1.0.3: The platform "linux" is incompatible with this module.
info "vscode-windows-registry@1.0.3" is an optional dependency and failed compatibility check. Excluding it from installation.info windows-foreground-love@0.2.0: The platform "linux" is incompatible with this module.
info "windows-foreground-love@0.2.0" is an optional dependency and failed compatibility check. Excluding it from installation.info windows-mutex@0.3.0: The platform "linux" is incompatible with this module.
info "windows-mutex@0.3.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-process-tree@0.2.4: The platform "linux" is incompatible with this module.
info "windows-process-tree@0.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @coder/logger@1.1.16" has unmet peer dependency "@google-cloud/logging@^4.5.2".
warning " > eslint-plugin-mocha@8.0.0" has incorrect peer dependency "eslint@>=7.0.0".
warning " > gulp-tsb@4.0.5" has incorrect peer dependency "typescript@^3.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 694.93s.
pi@server:~/.config/yarn/global/node_modules/code-server/lib/vscode $
jsjoeio commented 3 years ago

Great. All that looks fine to me. What version of node and yarn are you using?

node --version
yarn --version

And have you tried the suggestion by @code-asher ?

Playit3110 commented 3 years ago

I have. It is the first log i commented above.

Here the versions:

Last login: Tue Mar  2 18:32:09 2021 from 192.168.2.xxx
pi@server:~ $ yarn --version
1.22.5
pi@server:~ $ node --version
v14.16.0
pi@server:~ $
jsjoeio commented 3 years ago

Ah, sorry missed that!

Hmm...I wonder if it could be an issue with your node version. I know I've run into funky errors with local development and vscode itself recommends <= 14.x

Can you try downgrading node versions to either something that is>= 10.x and <= 14.x and then reinstalling code-server?

Playit3110 commented 3 years ago

Im sorry to ask but how can i downgrade. I dont work that much with node

jsjoeio commented 3 years ago

No worries at all! I usually use a tool called nvm. Here's a ~1min video about using nvm: link

What you'll do is something like:

  1. install nvm
  2. install an older version of node: nvm install 12.16.1
  3. set the default to that version: nvm alias default 12.16.1
  4. restart your shell
Playit3110 commented 3 years ago

It works now. Thanks a lot. :)

Playit3110 commented 3 years ago

I think we need to install the right version of node to make it working for other people.

Playit3110 commented 3 years ago

One thing, is there a easy way to rebuilt code-server if it is already installed?

jsjoeio commented 3 years ago

Yes, we should update the docs. I'll change this issue to match that.

jsjoeio commented 3 years ago

One thing, is there a easy way to rebuilt code-server if it is already installed?

Hmm... sorry can you elaborate a little bit on what you mean? If you have it installed with yarn, you shouldn't have to rebuild it hopefully, only stop/restart.

Playit3110 commented 3 years ago

If that works then it is ok

jsjoeio commented 3 years ago

Should we close this now?

Playit3110 commented 3 years ago

Sure

Playit3110 commented 3 years ago

But i cant close it

jsjoeio commented 3 years ago

ha! no worries, i can!

jsjoeio commented 3 years ago

actually, i still want us to update the docs. so we'll close after we do that!

Playit3110 commented 3 years ago

Thats a good idea

Vishalrakse commented 1 year ago

Screenshot_2023-03-27-10-32-36-36_84d3000e3f4017145260f7618db1d683.jpg

Pleas help me help me help me I am vishal I belong to bhopal. And Thank so much Pleas replay Tha setuation.

code-asher commented 1 year ago

You will need to use Node v16 with code-server, not v19.

https://github.com/coder/code-server/blob/main/docs/termux.md