Install Bun JS In Windows

Install Bun JS In Windows

Bun is a faster JavaScript runtime which uses the JavaScriptCore engine, which starts and perform faster than more traditional choices. Currently a beta version of Bun is released and we will be seeing how to install Bun JS in Windows.

Table of contents

Install Bun JS Youtube Video

To Installing Bun JS in Windows we have to turn on Windows subsystem for Linux.

Turn on Windows Subsystem for Linux

  1. Search for “Windows Features” , select the option Turn Windows features on or off
  2. Scroll down and select select the option Windows SubSystem for Linux, tick the box and click ok. Wait till the process completes and click Restart. You have to restart the system to complete the process.
  3. Now you have enabled Windows SubSystem for Linux.
Turn Windows features on or off

Now you have to download and install Ubuntu CLI in Windows.

Download Linux Ubuntu CLI

  1. Open Windows Store and search for Ubuntu
  2. Select any version of Ubuntu and install it.
  3. Open it and wait till the installation completes.
  4. It will ask to set username and password, select any username and password of your preference.
  5. Now you have installed Ubuntu CLI in Windows
Install Ubuntu CLI in Windows

Now we can get to the process of installing Bun JS.

Install Bun JS In Windows

  1. After completing the above steps to enable Windows Subsystem for Linux and installing Ubuntu CLI, you can start with Bun JS Installation.
  2. We have to install unzip in Ubuntu first. Type
    sudo apt install unzip
    and hit enter. If it asks for password enter the password for your Ubuntu system.
  3. Now go to the website Bun.sh and and you can see more details about Bun.
  4. Now open Ubuntu CLI and paste and run the code
    curl https://bun.sh/install | bash
  5. After installation it will get some details along with the path we need to add. We have to add the given path to the .bashrc file. To copy the path select the given path using the mouse and click CTRL + C
  6. Now open the file in nano. For that type
    nano ~/.bashrc
    and hit enter.
  7. It will open the file inside nano so that we can edit the file. Go to the bottom of the file using keyboard arrow keys and paste the copied path there. To paste simply right click the mouse on the position to paste.
  8. Now click CTRL + X, it will ask to save hit Y and hit enter key once more to exit.
  9. You have added the path and now you can access bun from the terminal.
  10. Check the bun version using the command bun - version
  11. Now you can create a new file and add some demo code and try running it.
  12. Create a folder using the command mkdir bun-js and after that go to the directory using cd bun-js
  13. Create a new file
    cat > http.js
    and hit enter. Copy the demo code and paste it here and type CTRL + D to save and exit
  14. Now you can run the file using bun run http.js and can see the result at http://localhost:3000
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};

That's all on how to Install Bun JS in Windows. If you have any doubts feel free to check the complete video and you can also ask you question on the comment section.