<blockquote>
<p dir="auto">Issue originally made by Chet Corcos (chet)</p>
</blockquote>
<h3 dir="auto">Bug information</h3>
<ul dir="auto">
<li><strong>Babel version:</strong> latest</li>
<li><strong>Node version:</strong> latest</li>
<li><strong>npm version:</strong> latest</li>
</ul>
<h3 dir="auto">Options</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="I want to create a folder that hides the complexity of npm and babel and all that. But babel doesnt seem to be happy about that. See the code snippet:"><pre class="notranslate"><code class="notranslate">I want to create a folder that hides the complexity of npm and babel and all that. But babel doesnt seem to be happy about that. See the code snippet:
</code></pre></div>
<h3 dir="auto">Input code</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="mkdir babel-issue
cd babel-issue

# hide the setup complexity in some hidden folder
mkdir .setup
mkdir src

# a basic node app (that uses babel)
cd src
echo &quot;console.log('hello world');&quot; &gt; index.js

# hide the configuration stuff
cd ../.setup
npm init -y
npm install --save-dev babel-cli babel-preset-es2015

# run babel on the node app
babel-node ../src/index.js --presets es2015
# Error: Couldn't find preset &quot;es2015&quot; relative to directory &quot;/Users/chet/Desktop/babel-issue/src&quot;

ln -s ../src .
babel-node src/index.js --presets es2015
# Error: Couldn't find preset &quot;es2015&quot; relative to directory &quot;/Users/chet/Desktop/babel-issue/src&quot;"><pre class="notranslate"><span class="pl-s1">mkdir</span> <span class="pl-s1">babel</span><span class="pl-c1">-</span><span class="pl-s1">issue</span>
<span class="pl-s1">cd</span> <span class="pl-s1">babel</span><span class="pl-c1">-</span><span class="pl-s1">issue</span>

# <span class="pl-s1">hide</span> <span class="pl-s1">the</span> <span class="pl-s1">setup</span> <span class="pl-s1">complexity</span> <span class="pl-k">in</span> <span class="pl-s1">some</span> <span class="pl-s1">hidden</span> <span class="pl-s1">folder</span>
<span class="pl-s1">mkdir</span> <span class="pl-kos">.</span><span class="pl-c1">setup</span>
<span class="pl-s1">mkdir</span> <span class="pl-s1">src</span>

# <span class="pl-s1">a</span> <span class="pl-s1">basic</span> <span class="pl-s1">node</span> <span class="pl-en">app</span> <span class="pl-kos">(</span><span class="pl-s1">that</span> <span class="pl-s1">uses</span> <span class="pl-s1">babel</span><span class="pl-kos">)</span>
<span class="pl-s1">cd</span><span class="pl-kos"></span> <span class="pl-s1">src</span>
<span class="pl-s1">echo</span> "<span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'hello world'</span><span class="pl-kos">)</span><span class="pl-kos">;</span><span class="pl-s">" &gt; index.js</span>
<span class="pl-s"></span>
<span class="pl-s"># hide the configuration stuff</span>
<span class="pl-s">cd ../.setup</span>
<span class="pl-s">npm init -y</span>
<span class="pl-s">npm install --save-dev babel-cli babel-preset-es2015</span>
<span class="pl-s"></span>
<span class="pl-s"># run babel on the node app</span>
<span class="pl-s">babel-node ../src/index.js --presets es2015</span>
<span class="pl-s"># Error: Couldn't find preset "</span><span class="pl-s1">es2015</span><span class="pl-s">" relative to directory "</span><span class="pl-c1">/</span><span class="pl-v">Users</span><span class="pl-c1">/</span><span class="pl-s1">chet</span><span class="pl-c1">/</span><span class="pl-v">Desktop</span><span class="pl-c1">/</span><span class="pl-s1">babel</span><span class="pl-c1">-</span><span class="pl-s1">issue</span><span class="pl-c1">/</span><span class="pl-s1">src</span><span class="pl-s">"</span>
<span class="pl-s"></span>
<span class="pl-s">ln -s ../src .</span>
<span class="pl-s">babel-node src/index.js --presets es2015</span>
<span class="pl-s"># Error: Couldn't find preset "</span><span class="pl-s1">es2015</span><span class="pl-s">" relative to directory "</span><span class="pl-c1">/</span><span class="pl-v">Users</span><span class="pl-c1">/</span><span class="pl-s1">chet</span><span class="pl-c1">/</span><span class="pl-v">Desktop</span><span class="pl-c1">/</span><span class="pl-s1">babel</span><span class="pl-c1">-</span><span class="pl-s1">issue</span><span class="pl-c1">/</span><span class="pl-s1">src</span>"</pre></div>
<h3 dir="auto">Description</h3>
<p dir="auto">I'm trying to run <code class="notranslate">babel</code> on a JSX file outside the project root (this happens in unit test when using a temporary directory under <code class="notranslate">/private/tmp</code>). It seems that babel fails to find presets installed into the same <code class="notranslate">node_modules</code> directory as <code class="notranslate">babel-cli</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="michi ~/Documents$ mkdir babel-preset-issue
michi ~/Documents$ cd babel-preset-issue/
michi ~/Documents/babel-preset-issue$ npm install babel-cli babel-preset-es2015
[...]
michi ~/Documents/babel-preset-issue$ echo 'a = 123;' &gt; ../foo.jsx
michi ~/Documents/babel-preset-issue$ node_modules/.bin/babel --presets=es2015 ../foo.jsx
Error: Couldn't find preset &quot;es2015&quot; relative to directory &quot;..&quot;
    at /Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/index.js:216:65)
    at new File (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/index.js:139:24)
    at Pipeline.transform (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transform (/Users/michi/Documents/babel-preset-issue/node_modules/babel-cli/lib/babel/util.js:50:22)"><pre class="notranslate"><code class="notranslate">michi ~/Documents$ mkdir babel-preset-issue
michi ~/Documents$ cd babel-preset-issue/
michi ~/Documents/babel-preset-issue$ npm install babel-cli babel-preset-es2015
[...]
michi ~/Documents/babel-preset-issue$ echo 'a = 123;' &gt; ../foo.jsx
michi ~/Documents/babel-preset-issue$ node_modules/.bin/babel --presets=es2015 ../foo.jsx
Error: Couldn't find preset "es2015" relative to directory ".."
    at /Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/index.js:216:65)
    at new File (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/file/index.js:139:24)
    at Pipeline.transform (/Users/michi/Documents/babel-preset-issue/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transform (/Users/michi/Documents/babel-preset-issue/node_modules/babel-cli/lib/babel/util.js:50:22)
</code></pre></div>
<p dir="auto">I've tested this with Babel 6.23.0 (babel-core 6.23.1) on OS X 10.11.6.</p>