Install Bun on WSL

hanancs

Ben Subendran

Posted on July 10, 2022

Install Bun on WSL

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:

Image description

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

If there's any error occurs while unzipping, install the unzip package like this:

sudo apt install unzip
Enter fullscreen mode Exit fullscreen mode

Now you can unzip it, and the installation will be done in seconds.

To check the installed Bun version, run this:

bun -version
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Installed path will be like this: wsl.localhost\Ubuntu\home\USER\myapp

Image description

To start the React app, run these commands:

cd myapp
bun dev
Enter fullscreen mode Exit fullscreen mode

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.

💖 💪 🙅 🚩
hanancs
Ben Subendran

Posted on July 10, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Install Bun on WSL
javascript Install Bun on WSL

July 10, 2022