title: NPM cannot install dependencies - Attempt to unlock something which hasn't been locked
body: <p>I've been trying to run an npm install on my package.json file, but I'm having a lot of trouble.  It keeps saying "Error:  Attempt to unlock XXX, which hasn't been locked" on all my dependences.  Here's one of them:</p>
  
  <pre><code>Error: Attempt to unlock tbd@~0.6.4, which hasn't been locked
          at unlock (/usr/local/lib/node_modules/npm/lib/cache.js:1304:11)
          at cb (/usr/local/lib/node_modules/npm/lib/cache.js:646:5)
          at /usr/local/lib/node_modules/npm/lib/cache.js:655:20
          at /usr/local/lib/node_modules/npm/lib/cache.js:1290:7
          at /usr/local/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
          at OpenReq.Req.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:144:5)
          at OpenReq.done (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:64:22)
          at Object.oncomplete (fs.js:107:15)
  </code></pre>
  
  <p>If I try to run it as sudo, it seems to get further and start installing some packages, but some new errors popup instead:</p>
  
  <pre><code>&gt; chokidar@0.8.1 postinstall /Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/chokidar
  &gt; node setup-deps.js
  
  shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
  
  node.js:811
      var cwd = process.cwd();
                        ^
  Error: EACCES, permission denied
      at Function.startup.resolveArgv0 (node.js:811:23)
      at startup (node.js:58:13)
      at node.js:902:3
  npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q'
  npm ERR! error rolling back  karma@0.10.9 { [Error: ENOTEMPTY, rmdir '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q']
  npm ERR! error rolling back   errno: 53,
  npm ERR! error rolling back   code: 'ENOTEMPTY',
  npm ERR! error rolling back   path: '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/q' }
  npm ERR! Error: ENOENT, chown '/Users/tkirchner/Documents/Projects/mm-datatable/node_modules/karma/node_modules/socket.io/lib/socket.io.js'
  </code></pre>
  
  <p>I recently updated my node and npm installations.  So maybe that has something to do with it.  Also, most of my development has been at the office and today I'm working over VPN, so maybe that has something to do with it too.</p>
  
  <p>Any ideas?</p>