npm - ENOENT, open <current_dir>/null

I'm running ubuntu 12.04 and my npm stopped working:

$ npm cache clean Error: ENOENT, open '/home/jasonshark/null'

I have npm 1.4.21 and node 0.10.30

Whenever I try to do anything with the npm I get null after the dir I'm in. what's going on?

I had the same problem, it's a nopt bug

Open /usr/lib/node_modules/npm/node_modules/npmconf/node_modules/nopt/lib/nopt.js and at line 127

function validatePath (data, k, val) {
  if (val === true) return false
  if (val === null) return true // <-- ADD THIS LINE !
  data[k] = path.resolve(String(val))
  return true
}

reference

Check this issue. A range of solutions have been given. This seems to fix it

sudo port uninstall npm
sudo rm -rf /opt/local/lib/node_modules/npm/
sudo port install npm