I’ve gotten some strange errors with npm which were resolved by clearing npm’s cache. The brute force method is:
sudo npm cache clean -f
This falls under the same category as strange C/C++ behaviour resolved by removing all .o files, strange Python behaviour resolved by removing all .pyc files. Caching or otherwise keeping around intermediaries is a boon for speed, but can bite when the cache gets stuffed up.