<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aakash</title>
    <description>The latest articles on DEV Community by Aakash (@aakash10802).</description>
    <link>https://dev.to/aakash10802</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1598213%2F82ae19f3-900f-453e-bfa1-05f7e9a98c6c.jpeg</url>
      <title>DEV Community: Aakash</title>
      <link>https://dev.to/aakash10802</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aakash10802"/>
    <language>en</language>
    <item>
      <title>Learn Bun.sh in Simple ways</title>
      <dc:creator>Aakash</dc:creator>
      <pubDate>Sun, 09 Jun 2024 13:13:11 +0000</pubDate>
      <link>https://dev.to/aakash10802/learn-bunsh-in-simple-ways-41l9</link>
      <guid>https://dev.to/aakash10802/learn-bunsh-in-simple-ways-41l9</guid>
      <description>&lt;p&gt;Bun.sh is a modern JavaScript runtime similar to Node.js, but it promises better performance and built-in tools for tasks such as bundling, transpiling, and running scripts.&lt;br&gt;
10 Facts about Bun.sh&lt;br&gt;
 &lt;a href="https://youtu.be/eTB0UCDnMQo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bun.sh is a modern JavaScript runtime designed for better performance than Node.js.&lt;/li&gt;
&lt;li&gt;It includes built-in tools for bundling, transpiling, and running scripts.&lt;/li&gt;
&lt;li&gt;Bun.sh supports hot reloading, making development faster and easier.&lt;/li&gt;
&lt;li&gt;It can directly run both JavaScript and TypeScript files without separate compilation steps.&lt;/li&gt;
&lt;li&gt;Bun.sh uses the npm ecosystem for managing dependencies.&lt;/li&gt;
&lt;li&gt;The installation of Bun.sh can be done via a simple curl command or through npm.&lt;/li&gt;
&lt;li&gt;Bun.sh aims to simplify the development workflow with integrated tools and faster execution.&lt;/li&gt;
&lt;li&gt;It is designed to work seamlessly with existing JavaScript and TypeScript projects.&lt;/li&gt;
&lt;li&gt;Bun.sh provides a command-line interface for initializing new projects and managing builds.&lt;/li&gt;
&lt;li&gt;Its built-in bundler can create production-ready builds from your source code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpa5s7d4a5sazxfxl3c6i.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpa5s7d4a5sazxfxl3c6i.gif" alt="bun.sh" width="650" height="450"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Install Bun.sh&lt;/strong&gt;&lt;a href="https://bun.sh/docs/installation"&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To install Bun.sh, you'll need to run the following script from your terminal:&lt;/p&gt;

&lt;p&gt;for powershell(sh)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -fsSL https://bun.sh/install | bash

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Basic commands in bun.sh&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;##  Initialize   a new project&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;For init a new project in  powershell(sh)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun init

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets up a new project directory with the necessary files.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Run a JavaScript or TypeScript file:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun run &amp;lt;file&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, to run index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//eg file name index.js
bun run index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Install dependencies:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun install &amp;lt;package-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Eg: To install express&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun install express

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Add Dependency to your Project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bun add &amp;lt;package-name&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This will add the package to your package.json and install it.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Remove a dependency from your project:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun remove &amp;lt;package-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Bundle your code:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun bundle &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;For example, to bundle index.js:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun bundle index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7.Run the project with hot reloading:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun run --hot &amp;lt;file&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;For example, to run server.js with hot reloading:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun run --hot server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8.Check the Bun.sh version:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  9.&lt;em&gt;Build your project for production:&lt;/em&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun build

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;This will create a production build of your project.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Update Bun.sh to the latest version:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bun upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands cover the basic functionalities you will use when working with Bun.sh, from initializing projects and running files to managing dependencies and building for production.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>bunjs</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
