To anybody who has tried all the above methods and still looking for a solution, try deleting .angular folder that is created at the root of your folder.
After deleting this folder I typed ionic serve (or any other npm command that you are trying to execute).
I'm using Ionic with Angular to develop an app. I got this error whenever I tried to run any npm commands within my app, and also while running ionic serve command (to build and launch the application on your browser).
.angular folder is created whenever you're trying to build the app (caching). Know more about .angular folder here.