<?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: Paul Melero</title>
    <description>The latest articles on DEV Community by Paul Melero (@paul_melero).</description>
    <link>https://dev.to/paul_melero</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%2F12876%2F1bf51be7-1847-4b27-8560-e2b3d1121ec3.jpg</url>
      <title>DEV Community: Paul Melero</title>
      <link>https://dev.to/paul_melero</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/paul_melero"/>
    <language>en</language>
    <item>
      <title>Installing GitHub repos or Gists directly as npm packages</title>
      <dc:creator>Paul Melero</dc:creator>
      <pubDate>Fri, 24 Jan 2020 10:07:37 +0000</pubDate>
      <link>https://dev.to/paul_melero/how-to-npm-install-from-github-repositories-or-gists-directly-6og</link>
      <guid>https://dev.to/paul_melero/how-to-npm-install-from-github-repositories-or-gists-directly-6og</guid>
      <description>&lt;p&gt;This is something that came across in our project that we think it's pretty useful. And despite now having the ability to host your own &lt;code&gt;npm&lt;/code&gt; packages on the &lt;a href="https://help.github.com/en/github/managing-packages-with-github-packages/about-github-packages"&gt;Github package Registry&lt;/a&gt;; some people might find this helpful, even if the repo itself didn't mean to be an &lt;code&gt;npm&lt;/code&gt; isntallable module.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install from a GitHub Repository
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npm install &amp;lt;githubname&amp;gt;/&amp;lt;githubrepo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That's the basic syntax, although you might want to use the explicit version:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npm install github:&amp;lt;githubname&amp;gt;/&amp;lt;githubrepo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;BTW, this works with private repos too! Also does &lt;a href="https://help.github.com/en/github/managing-packages-with-github-packages/about-github-packages"&gt;Github Package Registry&lt;/a&gt; ones. But it is possible that you will be prompted with the Git Credentials Manager to put your user/pass in order to continue.&lt;/p&gt;
&lt;h3&gt;
  
  
  Specify a version to install
&lt;/h3&gt;

&lt;p&gt;The good part, is that you can also specify versions (using &lt;strong&gt;semver&lt;/strong&gt;), as in every &lt;code&gt;npm&lt;/code&gt; package. And update them afterwards accordingly.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npm i github:&amp;lt;githubname&amp;gt;/&amp;lt;githubrepo&amp;gt;[#semver:&amp;lt;semver&amp;gt;]
# Example:
&amp;gt; npm i github:lodash/lodash#semver:4.17.15
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And another cool thing about this github option is that &lt;code&gt;npm&lt;/code&gt; allows you to specify specific &lt;strong&gt;commits&lt;/strong&gt; too!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npm i github:lodash/lodash#ddfd9b1 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;It will use the main branch in the respository, by default; usually &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing from a gist directly
&lt;/h2&gt;

&lt;p&gt;"Installing from a gist?" You might say. Sometimes it's useful to have little snippets that aren't as important as to make an npm package out of them in &lt;a href="//gist.github.com"&gt;Github Gists&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Take a look this example: &lt;a href="https://gist.github.com/gangsthub/0bce1161cfd2aa91ae7cad9abb42c342"&gt;https://gist.github.com/gangsthub/0bce1161cfd2aa91ae7cad9abb42c342&lt;/a&gt;&lt;/p&gt;


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



&lt;p&gt;If they have a &lt;code&gt;package.json&lt;/code&gt; properly configured, you can install them.&lt;/p&gt;

&lt;p&gt;You can then do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npm i gist:0bce1161cfd2aa91ae7cad9abb42c342
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Note, the hash is the id of the gist, also used in the URL.&lt;/p&gt;

&lt;p&gt;That's it! Also it's my first published post on Dev.to! Make sure to:&lt;/p&gt;

&lt;p&gt;❤ 😜&lt;/p&gt;

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