Quick build guide for visual studio code on the nano

After spending way too much time working on getting this to build I figure there might be one or two other people who could benefit from my pain. Note this will likely take an hour+ with frequent periods of 20 minutes or more where there wont be any apparent progress.

# Yarn package repo
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

# Install packages
sudo apt update
sudo apt install -y libx11-dev libxkbfile-dev libsecret-1-dev fakeroot npm curl nodejs nodejs-dev yarn

# Clone repo
git clone https://github.com/Microsoft/vscode.git
pushd vscode

# Reduce max_old_space_size
sed -i 's/4095/2048/g' package.json

# Kill the UI to free up memory ### WARNING THIS WILL DROP YOU TO A CONSOLE
sudo systemctl isolate multi-user

# Fetch deps, build, and create deb
yarn
yarn run gulp vscode-linux-arm64-min
yarn run gulp vscode-linux-arm64-build-deb
sudo dpkg -i ./.build/linux/deb/arm64/deb/code-oss_1.??.?-*_arm64.deb

# Reboot
code-oss

Nice! Thanks for sharing!

I am getting the following error during

yarn run gulp vscode-linux-arm64-min

[14:30:03] Finished optimize-index-js after 28 ms
[14:30:03] Starting minify-vscode ...
Killed
error Command failed with exit code 137.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Looks like you ran out of memory, if you already dropped to console by running isolate run top before trying to run min to identify any process that you can kill to free up the last couple MB

Thanks eousphoros, this worked flawlessly!

Alternatively, if you have memory issues you can set up a swap partition. This is something I found on DigitalOcean. I used this to build vscode, adding the swap partition before starting, and I skipped killing off the UI and the reboot. vscode built and runs just fine (so far).

You can turn off the swap file when done, and delete it, but I just turn it off in case I need it again

#from article: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
sudo swapon --show
sudo fallocate -l 1G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
echo "use sudo swapoff /swapfile"
echo "use sudo swapon --show"

And thanks eousphoros, this is great!

So trying to follow these instructions but when I run

# Kill the UI to free up memory ### WARNING THIS WILL DROP YOU TO A CONSOLE
sudo systemctl isolate multi-user

I don’t end up on a console where I can continue to add more commands. Screen goes black with a cursor in the top left. Guessing this kills keyboard support for some keyboards?

Tried putting them in a bash script and the followup commands also didn’t appear to run.

I just tried this and it worked for me. I get a login prompt, and can run things, then

systemctl isolate graphical.target

takes me back to multi-user. On my system I can do this multiple times. Not sure it makes any difference but are you using DisplayPort or HDMI?

I am using HDMI.

I got it to build by just removing that command and running the rest. I didn’t get any obvious out of memory errors or crashes when not running that command. It seems to register itself as code-oss, not visual studio code. It does boot up and works fine as a text editor.

I noticed extensions are not enabled by default. You have to go into the config in /usr/shared/code-oss/resources/app/product.json

and add the links from this stackoverflow question to get extensions.

For extensions, you may also check this.

Keep getting the error "Couldn’t find a package.json file in “/home/vecm”
After a run [yarn run gulp vscode-linux-arm64-min]
Not sure why?

@DM21 I don’t know how familiar you are with yarn etc, so excuse this if it is obvious, but when you run

yarn run gulp etc

you should be in the vscode directory where you cloned the code.

git clone ...etc
cd vscode
ls package.json

if a file called package.json is not there then you are either not in the right directory of the git clone failed.

I followed the first post for installation, except that after it failed once I upgraded nodejs to v10.15 as suggested by the Microsoft build guide.

I keep getting error messages in the re-build of the packages such as gc-signals. An error message looks like as follows. Any idea where I may find an answer? Since I haven’t really changed anything from the standard image, could it be that something got updated that now breaks the build? I have no experience at all with Yarn, so that leaves me a bit puzzled.

yarn install v1.15.2
$ node build/npm/preinstall.js
[1/4] Resolving packages...
[2/4] Fetching packages...
info vscode-fsevents@0.3.10: The platform "linux" is incompatible with this module.
info "vscode-fsevents@0.3.10" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.7: The platform "linux" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.4: The platform "linux" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
info vscode-windows-ca-certs@0.1.0: The platform "linux" is incompatible with this module.
info "vscode-windows-ca-certs@0.1.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info vscode-windows-registry@1.0.1: The platform "linux" is incompatible with this module.
info "vscode-windows-registry@1.0.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-foreground-love@0.1.0: The platform "linux" is incompatible with this module.
info "windows-foreground-love@0.1.0" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-mutex@0.2.1: The platform "linux" is incompatible with this module.
info "windows-mutex@0.2.1" is an optional dependency and failed compatibility check. Excluding it from installation.
info windows-process-tree@0.2.3: The platform "linux" is incompatible with this module.
info "windows-process-tree@0.2.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/13] ⠁ gc-signals
[2/13] ⠁ keytar
[3/13] ⠂ native-is-elevated
[4/13] ⠂ native-keymap
error /home/johannes/vscode/node_modules/gc-signals: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments: 
Directory: /home/johannes/vscode/node_modules/gc-signals
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.15.3 | linux | arm64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/nodejs/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/johannes/vscode/node_modules/gc-signals/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/nodejs/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/johannes/.node-gyp/iojs-3.1.8/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/johannes/.node-gyp/iojs-3.1.8',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/nodejs/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/johannes/.node-gyp/iojs-3.1.8/<(target_arch)/iojs.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/johannes/vscode/node_modules/gc-signals',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/johannes/vscode/node_modules/gc-signals/build'
  CXX(target) Release/obj.target/gcsignals/src/gcsignal.o
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:54:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5516:3: error: unterminated comment
   /**
   ^
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:54:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:15:0: error: unterminated #ifndef
 #ifndef INCLUDE_V8_H_
 
In file included from /home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8-platform.h:13:0,
                 from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:55,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5516:3: error: unterminated comment
   /**
   ^
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:15:0: error: unterminated #ifndef
 #ifndef INCLUDE_V8_H_
 
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/callback_scope.h:5:0,
                 from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:57,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5516:3: error: unterminated comment
   /**
   ^
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:15:0: error: unterminated #ifndef
 #ifndef INCLUDE_V8_H_
 
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/exceptions.h:5:0,
                 from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:58,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5516:3: error: unterminated comment
   /**
   ^
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:15:0: error: unterminated #ifndef
 #ifndef INCLUDE_V8_H_
 
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node_object_wrap.h:25:0,
                 from ../src/gcsignal.h:7,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5516:3: error: unterminated comment
   /**
   ^
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:15:0: error: unterminated #ifndef
 #ifndef INCLUDE_V8_H_
 
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:55:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8-platform.h:15:1: error: expected unqualified-id before ‘namespace’
 namespace v8 {
 ^~~~~~~~~
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:57:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/src/callback_scope.h:7:1: error: expected unqualified-id before ‘namespace’
 namespace node {
 ^~~~~~~~~
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:58:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/src/exceptions.h:7:1: error: expected unqualified-id before ‘namespace’
 namespace node {
 ^~~~~~~~~
In file included from ../src/gcsignal.h:5:0,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/src/node.h:64:1: error: expected unqualified-id before ‘namespace’
 namespace v8 {
 ^~~~~~~~~
/home/johannes/.node-gyp/iojs-3.1.8/src/node.h:70:1: error: expected unqualified-id before ‘namespace’
 namespace node {
 ^~~~~~~~~
In file included from /usr/include/features.h:424:0,
                 from /usr/include/aarch64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdint.h:26,
                 from /usr/lib/gcc/aarch64-linux-gnu/7/include/stdint.h:9,
                 from /home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:19,
                 from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:54,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/usr/include/assert.h:66:1: error: expected unqualified-id before string constant
 __BEGIN_DECLS
 ^
In file included from ../src/gcsignal.h:5:0,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/src/node.h:122:1: error: expected unqualified-id before ‘namespace’
 namespace node {
 ^~~~~~~~~
In file included from ../src/gcsignal.h:7:0,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/src/node_object_wrap.h:29:1: error: expected unqualified-id before ‘namespace’
 namespace node {
 ^~~~~~~~~
In file included from ../src/gcsignal.cc:2:0:
../src/gcsignal.h:9:1: error: expected unqualified-id before ‘namespace’
 namespace gcsignals {
 ^~~~~~~~~
In file included from ../src/gcsignal.cc:3:0:
/home/johannes/.node-gyp/iojs-3.1.8/deps/uv/include/uv.h:27:8: error: expected unqualified-id before string constant
 extern "C" {
        ^~~
../src/gcsignal.cc:6:1: error: expected unqualified-id before ‘namespace’
 namespace gcsignals {
 ^~~~~~~~~
../src/gcsignal.cc:96:1: error: expected ‘}’ at end of input
 }  // namespace gcsignals
 ^
In file included from /home/johannes/.node-gyp/iojs-3.1.8/src/node.h:54:0,
                 from ../src/gcsignal.h:5,
                 from ../src/gcsignal.cc:2:
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5510:59: error: expected unqualified-id at end of input
       ConstructorBehavior behavior = ConstructorBehavior::kAllow);
                                                           ^~~~~~
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:5510:59: error: expected ‘}’ at end of input
/home/johannes/.node-gyp/iojs-3.1.8/deps/v8/include/v8.h:3350:19: warning: inline function ‘void* v8::Object::GetAlignedPointerFromInternalField(int)’ used but never defined
   V8_INLINE void* GetAlignedPointerFromInternalField(int index);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcsignals.target.mk:97: recipe for target 'Release/obj.target/gcsignals/src/gcsignal.o' failed
make: Leaving directory '/home/johannes/vscode/node_modules/gc-signals/build'
make: *** [Release/obj.target/gcsignals/src/gcsignal.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.9.140-tegra
gyp ERR! command "/usr/local/lib/nodejs/bin/node" "/usr/local/lib/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/johannes/vscode/node_modules/gc-signals

Node is the JavaScript runtime built on the V8 JavaScript engine. You can create binding between V8 and native C/C++ code with gyp. What you are seeing is attempt to build those binding that fails. One of the problems is that the binding can get out of sync between versions of node. It is a bit fragile. Without looking into this particular issue in depth, my suggestion is that you can best solve this problem by using a different version of node. There is a node version manager nvm https://github.com/nvm-sh/nvm that is easy to install and pretty bullet proof in my experience.

You do have to make sure that nvm is in your path per the instructions of nvm which may mean completely logging out and logging back in.

My suggestion is to install nvm, then use nvm to install v11.14.0 and try that.

nvm install v11.14.0
node --version

That should report v11.14.0. If typing nvm gives an error then your path is wrong.

Next is that node comes with a package manager, npm and yarn is a Facebook alternative to npm. Both of these have various issues, but I personally prefer npm. You can use npm by simply replacing “yarn” with “npm” in the first (and other) posts. Either should work but for each version of node pick one and use it exclusively.

Using node v11.14.0 and npm and addressing the memory issues, I was able to compile vscode easily but not quickly.

Thanks for your feedback! With your instructions using nvm, I have tried out different versions of node.js, and also tried npm (analogous to yarn, which actually means yarn install, I used npm install). However, Version 11.14 was not accepted, it exited with “*** Please use node >=8 and <11”. Other versions of node, like 8 or 10, did not accept npm install, and said to use yarn instead.

However, I did checkout an older version with

git checkout 1.32.3

and it is compiling now just fine with Node v.10.15.3 and yarn install. The problem seemed to be in the newest release of vscode.

Pre-built deb link : https://drive.google.com/open?id=1JI_38MIpu6uQ7hyoVwBBbYVYLMSbuJrW

My nano installed smoothly once I removed line 17

Kill the UI to free up memory ### WARNING THIS WILL DROP YOU TO A CONSOLE

sudo systemctl isolate multi-user

from the first example

Thank you very much!

Can be the link wrong? I can’t use it :(