The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Npm - stopped working unexpectedly
OS: Linux Yocto V2.2.0. (on IoT2040)
Every command I try to run gives me this error: (ex. npm -v or npm cache clean)
I had the NODE-RED environment running for 6 months and now without doing anything the npm module is no longer working ( node-red was started using pm2 package)
That looks like something inserted malicious code into your copy of npm in some way. Have you tried a complete reinstall?
I have not tried this yet because I have many packages that depend on npm and it takes me a long time to reinstall all of them. But I think this will be the only solution after all.