Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiTelteu/cb7c162c93f91aad73fa4ed120a77dec to your computer and use it in GitHub Desktop.
Save AndreiTelteu/cb7c162c93f91aad73fa4ed120a77dec to your computer and use it in GitHub Desktop.
Install vs code-server with fnm and yarn, and keep it runing always with supervisor (on ubuntu)

Install build requirements (python3 and build essential)

sudo apt-get install -y build-essential pkg-config python3

Install fnm to manage multiple nodejs versions (uninstall nodejs or nvm if you have it installed)

curl -fsSL https://fnm.vercel.app/install | bash

Install node v14, yarn and code-server

fnm install 14
fnm default 14
npm install --global yarn
yarn global add code-server

Install supervisor (if you already have supervisor from a control pannel like aapanel, skip this)

Follow this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps

Create a config file for a vscode daemon (/etc/supervisor/conf.d/vscode.conf)

[program:vscode-server]
command=su - ubuntu -c "/home/ubuntu/.fnm/fnm exec --using 14 node /home/ubuntu/.yarn/bin/code-server"
directory=/home/ubuntu
autostart=true
autorestart=true
stopasgroup=true
startsecs=3
user=root
numprocs=1

Replace ubuntu with the username that you installed code-server with.


If you have problems after a server reboot try this method instead: Replace the command options in the supervysor config with:

command=/home/ubuntu/.code-start
user=ubuntu

Put this script in your home directory: /home/ubuntu/.code-start

#!/usr/bin/bash
export HOME=/home/ubuntu/
export PATH=/home/ubuntu/.fnm:$PATH
eval "`fnm env`"

fnm exec --using 14 node /home/ubuntu/.yarn/bin/code-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment