title: Installing an npm module as a devDependency of itself
body: <p>Let's say I've made a TDD tool called <strong>foo</strong>, and I want to use <strong>foo v1</strong> to help me develop <strong>foo v2</strong>.</p>
  
  <p>But when I <code>npm install --save-dev foo@^1.0.0</code>, npm says "Refusing to install foo as a dependency of itself".</p>
  
  <ol>
  <li>Why does npm refuse to do this?</li>
  <li>What can I do instead?</li>
  </ol>
  
  <p>Workarounds I've got so far (and why they're not good enough):</p>
  
  <ul>
  <li><p><strong>Workaround 1:</strong> just require the relevant script directly using a relative require, e.g. <code>require('../lib')</code> (this is how <a href="https://github.com/mochajs/mocha/blob/master/test/suite.js" rel="nofollow">mocha does it</a>, and it's how I've been doing it so far).</p>
  
  <ul>
  <li><strong>but</strong> if you're working on a new version of your module, adding features, perhaps even removing old features, then you're constantly having to alter not just the content of your tests but also their <em>format</em>, because you're actually using the thing you're working on to test the thing you're working on. If it breaks, you have to fix it in the dark with no tests to guide you. It would be much better to use the <em>settled</em> v1 API for tdd-ing the new v2 API.</li>
  </ul></li>
  <li><p><strong>Workaround 2:</strong> publish a duplicate of your module to npm under a different name, like "foo-clone". (Then you can just install foo-clone as a devDependency of foo.)</p>
  
  <ul>
  <li><strong>but</strong> that seems messy and a misuse of npm. Anyway, if installing an exact clone would work, then what would be the harm in npm allowing me to install [an old version of] foo as a devDependency of foo?</li>
  </ul></li>
  </ul>