<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Simplify - Articles tagged with Shell</title>
  <subtitle>Personal website of Saša Jovanić</subtitle>
  <id>https://www.simplify.ba/articles/tags/shell/</id>
  <link href="https://www.simplify.ba/articles/tags/shell/"/>
  <link href="https://www.simplify.ba/articles/tags/shell/feed.xml" rel="self"/>
  <updated>2021-12-17T19:12:00+01:00</updated>
  <author>
    <name>Saša Jovanić</name>
  </author>
  <entry>
    <title>node_modules/.bin in your project $PATH</title>
    <link rel="alternate" href="https://www.simplify.ba/articles/2016/02/14/node-modules-bin-in-path/"/>
    <id>https://www.simplify.ba/articles/2016/02/14/node-modules-bin-in-path/</id>
    <published>2016-02-14T14:14:00+01:00</published>
    <updated>2016-02-18T14:59:19+01:00</updated>
    <author>
      <name>Saša Jovanić</name>
    </author>
    <content type="html">&lt;p&gt;Just to remind myself in the future. Add this to &lt;code&gt;.bash_profile&lt;/code&gt; or &lt;code&gt;.profile&lt;/code&gt; in order to have per project installed node modules executable in $PATH:&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;:node_modules/.bin"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately, this works only in root project directory, not when I use &lt;abbr title="GNU is Not Unix"&gt;GNU&lt;/abbr&gt; Emacs. Solution is to use &lt;code&gt;.dir-locals.el&lt;/code&gt; file in project directory with following code inside:&lt;/p&gt;

&lt;pre class="highlight common_lisp"&gt;&lt;code&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;progn&lt;/span&gt;
                   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;add-to-list&lt;/span&gt; &lt;span class="ss"&gt;'exec-path&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;concat&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;locate-dominating-file&lt;/span&gt; &lt;span class="nv"&gt;default-directory&lt;/span&gt; &lt;span class="s"&gt;".dir-locals.el"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="s"&gt;"node_modules/.bin/"&lt;/span&gt;&lt;span class="p"&gt;)))))))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you start &lt;abbr title="GNU is Not Unix"&gt;GNU&lt;/abbr&gt; Emacs somewhere in your project directory, he will ask do you want to apply local settings. You can answer with 'y' or '!' (to apply those permanently). That will add &lt;code&gt;$(your project)/node_modules/.bin&lt;/code&gt; to your $PATH inside &lt;abbr title="GNU is Not Unix"&gt;GNU&lt;/abbr&gt; Emacs. No need to install any &lt;abbr title="Node package manager"&gt;npm&lt;/abbr&gt; modules globally any more.&lt;/p&gt;

</content>
  </entry>
</feed>
