I recently upgraded to node 4.2.1 on a Windows 7 x64 machine. When running
npm install -g bower
I got a similar error:
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\THE_USERNAME\AppData\Local\Temp\npm-THE_HASH'
Thinking it was related to the AppData path, I played around with
npm config edit
and
npm config edit --global
to change the prefix, cache and tmp fields but received the same error with the new paths:
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\THE_USERNAME\npm-temp\npm-THE_HASH'
All commands were run as Administrator, so I had full permissions.
Then I thought there were some issues with existing files so I ran:
npm cache clean
But got the same error. However, there were still some temp files lying around. Manually removing all temp data with cygwin finally fixed the problem for me:
rm -rf bower bower.cmd node_modules etc
If you only have Windows cmd, you could use something like
rmdir /S THE_TEMP_DIR
to remove all subdirectories (although if you have deeply nested node dependencies, this is notoriously problematic)
So, maybe there is some issues with upgrading npm and having versions of bower or other packages hanging around. In my case that seemed to be the problem