<?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: umamaheswararao tumma</title>
    <description>The latest articles on DEV Community by umamaheswararao tumma (@umamahesh51).</description>
    <link>https://dev.to/umamahesh51</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%2F558365%2Fb58ee4d4-3c15-42b8-aa1d-4adfeaaf462c.jpeg</url>
      <title>DEV Community: umamaheswararao tumma</title>
      <link>https://dev.to/umamahesh51</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/umamahesh51"/>
    <language>en</language>
    <item>
      <title>Executing Gists With Npx</title>
      <dc:creator>umamaheswararao tumma</dc:creator>
      <pubDate>Tue, 16 Mar 2021 11:52:06 +0000</pubDate>
      <link>https://dev.to/umamahesh51/executing-gists-with-npx-56ea</link>
      <guid>https://dev.to/umamahesh51/executing-gists-with-npx-56ea</guid>
      <description>&lt;p&gt;We all know that &lt;a href="https://gist.github.com/"&gt;Gists&lt;/a&gt; are a very good way to share code templates or embed code in our articles or website.&lt;/p&gt;

&lt;p&gt;If you don't know about Gists see &lt;a href="https://docs.github.com/en/github/writing-on-github/creating-gists"&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Apart from that, we can use Gists to create smaller and single-file scripts.&lt;/p&gt;

&lt;p&gt;To add more power, with the help of Npx, consumers can run these scripts from their command line.&lt;/p&gt;

&lt;p&gt;Let's consider a small example. Below are the Index.js and package.json files from my public gist.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The Link to the above gist is &lt;a href="https://gist.github.com/umamahesh51/797c37a1d51a1affdee01a96c74ebe33"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you have npm installed on your machine. If not installed refer to &lt;a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now open your command line/terminal, copy the below command, and paste&lt;br&gt;
&lt;br&gt;
 &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx https://gist.github.com/umamahesh51/797c37a1d51a1affdee01a96c74ebe33
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Hit enter, You will see the &lt;strong&gt;ok to proceed&lt;/strong&gt; question Like below.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ywLyvPmo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/umamahesh51/Images/raw/main/articles/npx-command.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ywLyvPmo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/umamahesh51/Images/raw/main/articles/npx-command.png" alt="Npx Command usage" title="Npx Command to run gist"&gt;&lt;/a&gt;&lt;br&gt;
type &lt;strong&gt;y&lt;/strong&gt;&lt;br&gt;
You will see the output like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tYTfMhp1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/umamahesh51/Images/raw/main/articles/output.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tYTfMhp1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/umamahesh51/Images/raw/main/articles/output.png" alt="Output after using NPX to run gist" title="Output after using NPX to run gist"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in the above example we have "bin":"./index.js" so the index.js file will be executed. &lt;/p&gt;

&lt;p&gt;It is the same as using the command&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;But instead of downloading the repository and then run the command, we are executing the package directly.&lt;/p&gt;

&lt;p&gt;It will be applicable to GitHub repositories as well.&lt;br&gt;
Try the npx with this &lt;a href="https://github.com/umamahesh51/TestGist"&gt;repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx https://github.com/umamahesh51/TestGist 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A famous and complex example of this case is &lt;a href="https://reactjs.org/docs/create-a-new-react-app.html"&gt;create-react-app&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How we can utilize this feature of gists?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can provide scripts that will do some useful things and share them with others, instead of building them and giving executable files, we can just provide a link to gist.&lt;/p&gt;

&lt;p&gt;Repositories will be useful if we have a complex task like create-react-app. Where as gists are a way to provide small scripts.&lt;/p&gt;

&lt;p&gt;My favorite useful gist which we can run using npx is &lt;br&gt;
&lt;a href="https://gist.github.com/elijahmanor/7f9762a4c2296839ad33e33513e88043"&gt;Export @code Extensions to a Markdown List&lt;/a&gt;&lt;br&gt;
Try it and see.&lt;/p&gt;

&lt;p&gt;That's all I have. Let me know if you have seen some interesting usages of Gists.&lt;/p&gt;

</description>
      <category>github</category>
      <category>gist</category>
    </item>
  </channel>
</rss>
