Again, Windows can cause problems you would not have expected. In npm versions prior to 3, npm stores dependencies in deeply nested folder structures, causing errors on running ‘npm install’ such as
npm ERR! Error: EPERM: operation not permitted, open '/var/www/my_longnamed_app/node_modules/ gulp-angular-templatecache/node_modules/ gulp-util/node_modules/dateformat/ node_modules/meow/node_modules/redent/ node_modules/indent-string/node_modules/ repeating/node_modules/is-finite/ package.json.29c584111ad29c009da7874ac2d19f55'
Obviously, this is a ridiculously long path and exceeds 260 characters – and Windows can’t handle that. Not sure why “they” (you know … MS…) came up with that idea, and why this is still not fixed in a modern OS like Windows 7 (I did not try versions above that). I guess it is just the pure essence of evil, the same diabolic power which brought the Internet Explorer amongst us. Let them burn, let them suffer, and let even pay money for it!
Even when you run npm on Linux in a VM on Windows with a Shared folder, you will still suffer from that. Oh, you beasts from the abyss, how … ok I’ll stop.
Luckily, npm3 supports flat dependencies, i.e. all dependencies are written into the top level of the node_modules folder. So if you run into the above problem, try
If this still says 2.x, consider updating to npm3:
npm install -g npm
Delete your node_modules folder (not sure if this is really needed, but better go sure), then run
and all dependencies get installed without errors. Yay!
If you dare, you can have a look into the node_modules folder now. You’ll find loads of folders – the beauty of flat dependencies.