<h3 dir="auto">Is there an existing issue for this?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the existing issues</li>
</ul>
<h3 dir="auto">Current Behavior</h3>
<p dir="auto">Deletes git repository.<br>
(Removed <code class="notranslate">.git</code> and tracked files)</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Install without error</p>
<h3 dir="auto">Steps To Reproduce</h3>
<ol dir="auto">
<li>Clone <a href="https://github.com/kdy1/swc.git">https://github.com/kdy1/swc.git</a></li>
<li>Checkout <code class="notranslate">resolver</code> branch</li>
<li>npm i</li>
<li>npm run build:dev</li>
<li>npm link</li>
<li>npm i -g @swc/cli</li>
</ol>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>OS: macOS Big Sur</li>
<li>Node:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="➜  swc-bugs node -v
v14.16.1"><pre class="notranslate"><code class="notranslate">➜  swc-bugs node -v
v14.16.1
</code></pre></div>
<p dir="auto">Note: I installed latest version of node js because of stack trace issue on github actions.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="➜  swc-bugs brew info node
node: stable 16.3.0 (bottled), HEAD
Platform built on V8 to build network applications
https://nodejs.org/
/usr/local/Cellar/node/14.4.0 (107 files, 650KB)
  Built from source
/usr/local/Cellar/node/15.12.0 (3,268 files, 55.5MB)
  Poured from bottle on 2021-03-31 at 15:11:58
/usr/local/Cellar/node/16.2.0 (2,784 files, 49MB) *
  Poured from bottle on 2021-05-30 at 20:06:55
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/node.rb
License: MIT
==&gt; Dependencies
Build: pkg-config ✔, python@3.9 ✔
Required: brotli ✔, c-ares ✔, icu4c ✔, libuv ✔, nghttp2 ✔, openssl@1.1 ✔
==&gt; Options
--HEAD
	Install HEAD version
==&gt; Analytics
install: 323,426 (30 days), 1,082,930 (90 days), 4,400,808 (365 days)
install-on-request: 254,200 (30 days), 847,506 (90 days), 3,304,651 (365 days)
build-error: 0 (30 days)"><pre class="notranslate"><code class="notranslate">➜  swc-bugs brew info node
node: stable 16.3.0 (bottled), HEAD
Platform built on V8 to build network applications
https://nodejs.org/
/usr/local/Cellar/node/14.4.0 (107 files, 650KB)
  Built from source
/usr/local/Cellar/node/15.12.0 (3,268 files, 55.5MB)
  Poured from bottle on 2021-03-31 at 15:11:58
/usr/local/Cellar/node/16.2.0 (2,784 files, 49MB) *
  Poured from bottle on 2021-05-30 at 20:06:55
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/node.rb
License: MIT
==&gt; Dependencies
Build: pkg-config ✔, python@3.9 ✔
Required: brotli ✔, c-ares ✔, icu4c ✔, libuv ✔, nghttp2 ✔, openssl@1.1 ✔
==&gt; Options
--HEAD
	Install HEAD version
==&gt; Analytics
install: 323,426 (30 days), 1,082,930 (90 days), 4,400,808 (365 days)
install-on-request: 254,200 (30 days), 847,506 (90 days), 3,304,651 (365 days)
build-error: 0 (30 days)
</code></pre></div>
<ul dir="auto">
<li>npm:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm@7.14.0 /Users/kdy1/.nvm/versions/node/v14.16.1/lib/node_modules/npm"><pre class="notranslate"><code class="notranslate">npm@7.14.0 /Users/kdy1/.nvm/versions/node/v14.16.1/lib/node_modules/npm
</code></pre></div>
<p dir="auto">Note that this same issue was reported back in 2017 on the now-archived repo: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="208071714" data-permission-text="Title is private" data-url="https://github.com/npm/npm/issues/15783" data-hovercard-type="issue" data-hovercard-url="/npm/npm/issues/15783/hovercard" href="https://github.com/npm/npm/issues/15783">npm/npm#15783</a></p>
<h3 dir="auto">Current Behavior:</h3>
<p dir="auto">I am using <code class="notranslate">npm link</code> to try to test changes I am making to an upstream dependency within my own project. In the dependency directory I run <code class="notranslate">npm link</code>. Then in my own project I run <code class="notranslate">npm link ffmpeg-stream</code>.</p>
<p dir="auto">NPM gives the following error message when running the second link command:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="npm ERR! code 1
npm ERR! path D:\git\node-ffmpeg-stream
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c &quot;tsc&quot;
npm ERR! Version 3.9.7
npm ERR! Syntax:   tsc [options] [file...]"><pre class="notranslate"><code class="notranslate">npm ERR! code 1
npm ERR! path D:\git\node-ffmpeg-stream
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c "tsc"
npm ERR! Version 3.9.7
npm ERR! Syntax:   tsc [options] [file...]
</code></pre></div>
<p dir="auto">Afterwards, the directory of the upstream dependency is empty. Even the <code class="notranslate">.git</code> directory is deleted, so tough luck if you haven't pushed recently.</p>
<h3 dir="auto">Expected Behavior:</h3>
<p dir="auto">NPM link should link the package without issue. If an error is encountered, NPM should not delete the entire folder contents.</p>
<h3 dir="auto">Steps To Reproduce:</h3>
<ol dir="auto">
<li>
<p dir="auto">Clone <code class="notranslate">https://github.com/JoshuaWalsh/node-ffmpeg-stream/</code></p>
</li>
<li>
<p dir="auto">Clone <code class="notranslate">https://github.com/JoshuaWalsh/subtitle-indexer</code></p>
</li>
<li>
<p dir="auto">In <code class="notranslate">node-ffmpeg-stream</code>, run <code class="notranslate">npm ci --include=prod</code></p>
</li>
<li>
<p dir="auto">In <code class="notranslate">node-ffmpeg-stream</code>, run <code class="notranslate">npm link</code></p>
</li>
<li>
<p dir="auto">In <code class="notranslate">subtitle-indexer</code>, run <code class="notranslate">npm link ffmpeg-stream</code></p>
</li>
<li>
<p dir="auto">Observe that the <code class="notranslate">node-ffmpeg-stream</code> directory is now empty. (A small number of files may remain if they were in use at the time and couldn't be deleted)</p>
</li>
</ol>
<h3 dir="auto">Environment:</h3>
<ul dir="auto">
<li>OS: Windows 10 Pro 10.0.19042</li>
<li>Node: 15.0.1</li>
<li>npm: 7.0.3</li>
</ul>
<p dir="auto">I am using <code class="notranslate">nvm-windows</code> to manage NodeJS, but currently only have one version installed.</p>