Building Visual Studio Code on a Raspberry Pi 3
I picked up a Raspberry Pi 3 recently for MarchIsForMakers. The Raspberry Pi 3 is a great starter computer for makers not just because it is faster than the Pi and Pi 2, but because it has Wifi built in! This makes setup and messing around a lot easier.
Here's some great tutorials for getting started with the Raspberry Pi, Node, and Visual Studio Code.
- Visual Studio Code Jumpstart for Node.js Developers
- Right click on Windows folder and open with Visual Studio Code
- Using Visual Studio Code (via a File Share) with a Raspberry Pi (Raspbian)
I also recommend folks setup a VNC Server for their Raspberry Pi so you can TightVNC (meaning, remote in and control) into the Pi from your PC. You can also setup your Raspberry Pi to share the clipboard so you can copy from Windows and Paste into the VNC window when you are remoted into your Pi.
But why not build Visual Studio Code and get it running natively on the Pi? Marc Gravell did it first on Twitter, but I wanted to figure out how he did it and if it was still possible (he did it before some significant refactoring) and also to see if VS Code was faster (or even usable) on a Rasberry Pi 3.
Compiling Visual Studio Code on a Raspberry Pi 3
From the VS Code GitHub, you need Node, npm, and Python. The Pi has Python but it has an old node, so needed a newer node that ran on ARM processors.
sudo dpkg -i node_latest_armhf.deb
There are some NPM native modules like node-native-keymap that didn't work when I built the first time, so you'll need some supporting libraries first:
sudo apt-get install libx11-dev
Then, from my Raspberry Pi, I did this to build my own instance of VS Code.
git clone https://github.com/microsoft/vscode
./scripts/npm.sh install --arch=armhf
This took the Raspberry Pi 3 about 20 minutes so be patient.
Then, run your instance with ./scripts/code.sh from that same folder.
Note: Electron and Chromium underneath it use some very specific features of X Servers like "xrandr" for dynamic resizing and you may have trouble getting Visual Studio Code to run under a remote VNC session. Consider using RealVNC or TigerVNC for your Raspberry Pi, rather than the older TightVNC. RealVNC is a commercial product but they'll give you a free license for your Raspberry Pi.
Once you've updated to a newer VNC you can run VS Code
Check out MarchIsForMakers all month long as we partner with CodeNewbies and play and learn with maker hardware! Last week we unboxed my Raspberry Pi 3, set it up, and got it to blink an LED!
What have YOU done with your Raspberry Pi? Sound off in the comments.
Sponsor: Big thanks to Redgate for sponsoring the feed this week! Feeling the pain of managing & deploying database changes by hand? New Redgate ReadyRoll creates numerically ordered SQL migration scripts to take your schema from one version to the next. Try it free!
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
I'm loving win 10 IoT with Pi2, my Pi3 arrives today, sadly the day after Pi day.
Seeing packages installed system-wide from HTTP sources screams out at me :)
I have my PI 2 set up as a security camera using motion pie
And i am planning to use my PI 3 to help control the temperature of my fermenting beer (turning heater/ fan on and off to keep a steady temperature).
I haven't thought of a good use for the PI zero.... yet.
Thanks foe the tutorial.
You might want to update the first command to use 'wget' instead of 'get'.
Only one small thing, nodejs-legacy hast to be uninstalled before you can install the latest version.
Coming from c#, I wanted to dig a little into python development. I am only getting used to VS Code on Windows, so I want to stick with it on my Pi.
Only thing I had to do in addition was to first update the legacy version of node before installing the latest arm version:
sudo apt-get update
sudo apt-get install node
really cool stuff, love coding on my pi 3
before installing the new node:
sudo apt-get uninstall node node-legacy
Comments are closed.