Raspberry Pi

How to Program Raspberry Pi Remotely Using a Browser with VS Code

VS Code is an open-source IDE that allows users to execute code in different programming languages. However, installing an IDE on a low-storage system like Raspberry Pi may be daunting for someone. So, those users who don’t want to install a VS code on the Raspberry Pi system can still do programming with VS code from a browser.

In this writeup, I will show you how to remotely program Raspberry Pi in a browser through VS Code.

How to Remotely Program Raspberry Pi Using a Browser with VS Code

To remotely program Raspberry Pi from a browser with VS Code, follow the below-given steps:

Step 1: First install Code-Server on the Raspberry Pi system from the following command:

curl -fsSL https://code-server.dev/install.sh | sh

The Code-Server is basically the server version of VS Code that can be accessed from any browser.

Step 2: Next, the user has to extend the path on the system from the following command to use Code-Server on Raspberry Pi.

PATH="$(npm bin -g):$PATH"

Step 3: Open the Code-Server configuration file using the following command:

sudo nano home/pi/.config/code-server/config.yaml

Step 4: Inside the file, replace the IP address “127.0.0.1” with the Raspberry Pi IP address and set the password according to your choice.

Step 5: Save the file using “CTRL+X”, add “Y” and use enter to exit.

Step 6: Run the Code-Server on the Raspberry Pi terminal from the following command:

code-server

Step 7: Go to any system browser and use the Raspberry Pi IP address with port 8080 to access the Code-Server.

http://<IP>:8080

While running the address on the browser, you may experience a “no-module error” as in my case.

You must create the symlink of the module in the global folder using the following command to fix the “no module found” error.

sudo npm link <module_name>

Note: You may experience multiple module errors and can fix them through the npm link command.

You must run the Code-Server multiple times until you see no module found error. Once the Code-Server runs successfully, you can then be able to access the Code-Server on the browser.

Step 8: Enter the password for Code-Server you set in Step 4 and hit the “Submit” button.

After successful login, you will see the VS Code on the browser.

At this point, the VS Code server is successfully set up on your Raspberry Pi system and you can access the Code-Server remotely using the Raspberry Pi’s IP address.

Conclusion

Code-Server is a web-based VS Code server that allows users to program with VS Code on the browser. You can set up the Code-Server on the Raspberry Pi system by installing the script and extending the path to the system. After that, you have to make some changes inside the Code-Server configuration file and then access it on the browser using the Raspberry Pi IP address. In case you experience a “no module found” error, you can fix it by creating the symlink of the module in the global folder from the “sudo npm link” command.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.