Generally this means that an existing, globally installed package is in bad shape. Possibly permissions related, but hard to say for sure without more information about the environment.
The solution lies in fixing the broken package. One way to do so is delete and re-install it. Try sudo npm uninstall -g <pkg>
where <pkg>
is anything you suspect may be broken.
If you are not sure where to start, do:
npm list -g --depth=0
That will show you all of your globally installed packages. Just remove and re-install them one by one.
If any of those throw errors during the removal process, you will need to do it yourself, manually.
First, figure out where global packages are installed. Generally, this will be /usr/local
on OS X, for example. To find out for sure:
npm config get prefix
Then explore that directory, especially /usr/local/bin
(for example) and if you are sure a file is related to a global npm package, it's usually safe to remove it.
`sudo rm -rf <file>`
... where <file>
is the actual filename you wish to delete.
You may have gotten into this mess due to overuse of sudo
.
See my answer to SNAFU with npm update -g on why sudo
is bad and instructions on how to fix it.