If you’re a web developer on a chromebook then chances are you’ll likely be needing to utilize Node.js and Yarn at some point. While there a handful of other tutorials out there on how to do this, I’ve powerwashed my chromebook enough times to figure what I think is the most efficient way to go about this.
As any good developer would say, let’s start by making sure your local environment is up to date. Go ahead and login to your terminal or shell application of choice and run:
sudo apt update
This will update any Linux dependencies on your local container. Even if you just enabled Linux on your Chromebook, I would still recommend doing this as I’ve seen updates come through directly after enabling.
Once up to date, head over to the nodesource distributions github page and search for the installation instructions for Ubuntu. At the time of writing, v16.x is the current stable version.
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -f
sudo apt-get install -y nodejs
NOTE: make sure you replace 16.x with whatever version you are wanting to install.
You should be able to run the following command next to ensure it got installed:
and you should get something like v16.0.0. If you don’t get anything or you get an error, try the above steps again or provide the error in a comment and I’ll do my best to help you out!
Once Node is installed, you can simply run the following command to get Yarn.js installed globally on your Chromebook:
npm install --global yarn
The global flag will install it on the container and make it accessible within any directory. If you run into any errors related to permissions then try running it as root by adding a sudo to the front of the command like this:
sudo npm install --global yarn
If everything goes as planned then you should now be able to run yarn -v to confirm.
#should output something like 1.22.10
That’s it! Simple and quick. Probably didn’t warrant an entire article but felt like it would be beneficial to someone else eventually.