Install Bun on WSL
Ben Subendran
Posted on July 10, 2022
Bun(https://bun.sh) is a new JavaScript runtime with a native bundler, transpiler, task runner and NPM client built-in. Bun is superfast compared to NodeJS.
Enable WSL from Windows Features
To turn on the Windows Subsystem for Linux feature, click the checkbox like this:
Install Linux Distro
- To work with WSL, you should have installed at least one distro on your computer.
To install Ubuntu, Run this:
winget install -e --id Canonical.Ubuntu
If you want to install any other distro, you can get it here by searching; https://winget.run/
After installed, To check all the available distros, run this:
wsl --list
- If you get any error, just update the wsl by running
wsl --update
. And install the distro again.
Install Bun
After setting up the Unix admin for the respective distro, run this(in your WSL terminal, not in CMD):
curl https://bun.sh/install | bash
If there's any error occurs while unzipping, install the unzip package like this:
sudo apt install unzip
Now you can unzip it, and the installation will be done in seconds.
To check the installed Bun version, run this:
bun -version
Try React on Bun
To scrutinize the specialty of Bun, we'll try installing React via Bun.
The following command will create a React project inside the myapp folder.
bun create react ./myapp
Installed path will be like this: wsl.localhost\Ubuntu\home\USER\myapp
To start the React app, run these commands:
cd myapp
bun dev
Now you can see your React app by navigating to http://localhost:3000.
All this can take significantly less time than NodeJS. That's the magic what Bun can do.
Posted on July 10, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.