<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
Installing webpack 4.8.1 in [dev] has an outdated dependency of deep-extend with this vulnerability <a href="https://snyk.io/vuln/npm:deep-extend:20180409" rel="nofollow">https://snyk.io/vuln/npm:deep-extend:20180409</a></p>
<p dir="auto">with the path:</p>
<p dir="auto">webpack &gt; watchpack &gt; chokidar &gt; fsevents &gt; node-pre-gyp &gt; rc &gt; deep-extend</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
Not to have security vulnerabilities in webpack</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  4.8.1<br>
Node.js version: 9.7.1<br>
Operating System: osx 10.13.3<br>
Additional tools:</p>
<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong></p>
<p dir="auto">bug</p>


<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto">While using webpack for server side packing of node.js apps I am unable to have an accurate value for __dirname when __dirname is called within a required module, regardless of what <code class="notranslate">options.node.__dirname</code> might be set to.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">For example, assume the following:</p>
<p dir="auto"><em>directory structure</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/my/app
   other
      file.js
   entry.js
   webpack.config.js"><pre class="notranslate"><code class="notranslate">/my/app
   other
      file.js
   entry.js
   webpack.config.js
</code></pre></div>
<p dir="auto"><em>/my/app/entry.js</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="require('./other/file.js');
console.log(__dirname);"><pre class="notranslate"><code class="notranslate">require('./other/file.js');
console.log(__dirname);
</code></pre></div>
<p dir="auto"><em>/my/app/other/file.js</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="console.log(__dirname);"><pre class="notranslate"><code class="notranslate">console.log(__dirname);
</code></pre></div>
<p dir="auto"><em>/my/app/webpack.config.js</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const path = require('path');
module.exports = {
    target: &quot;node&quot;,
    entry: {
      entry: './entry.js'
    },
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: '[name].js'
    },
    node: {
      __dirname: false
    },
  };"><pre class="notranslate"><code class="notranslate">const path = require('path');
module.exports = {
    target: "node",
    entry: {
      entry: './entry.js'
    },
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: '[name].js'
    },
    node: {
      __dirname: false
    },
  };
</code></pre></div>
<p dir="auto"><em>Steps to reproduce (assuming above files are in provided locations:</em></p>
<div class="highlight highlight-source-batchfile notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="cd /my/app
webpack
cd dist
node entry.js"><pre class="notranslate"><span class="pl-k">cd</span> /my/app
webpack
<span class="pl-k">cd</span> dist
node entry.js</pre></div>
<p dir="auto"><em>Expected Results:</em></p>
<div class="highlight highlight-source-batchfile notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/my/app/dist/other
/my/app/dist"><pre class="notranslate">/my/app/dist/other
/my/app/dist</pre></div>
<p dir="auto"><em>Actual Results:</em></p>
<div class="highlight highlight-source-batchfile notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="/my/app/dist
/my/app/dist"><pre class="notranslate">/my/app/dist
/my/app/dist</pre></div>
<p dir="auto">Results using the above files but based on various <code class="notranslate">options.node.__dirname</code> values within webpack.config.js:</p>
<table role="table">
<thead>
<tr>
<th>value of <code class="notranslate">options.node.__dirname</code></th>
<th>result</th>
</tr>
</thead>
<tbody>
<tr>
<td>false</td>
<td>/my/app/dist<br>/my/app/dist</td>
</tr>
<tr>
<td>true</td>
<td>other<br><em>empty line</em></td>
</tr>
<tr>
<td><em>unset</em></td>
<td>/<br>/</td>
</tr>
</tbody>
</table>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">I expect there to be an option to have <code class="notranslate">__dirname</code>'s location be in relation to the directory of the current module that it was called from (before webpack) and not the directory name of the output file.</p>
<p dir="auto"><strong>If this is a feature request, what is motivation or use case for changing the behavior?</strong></p>
<p dir="auto">N/A</p>
<p dir="auto"><strong>Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.</strong></p>
<ul dir="auto">
<li>Node 6.9.5 LTS</li>
<li>weback 2.2.1</li>
<li>Windows 10</li>
</ul>