so after a lot of trouble shooting, got to know that the node versions were different and conflicting. in the terminal, though the node version was the latest, some of the files of node older version were not deleted and hence got this error while npm install. so deleted the files manually, uninstalled latest version of node. reinstalled it.
after doing npm install --force, i got to know about the version mess.
somehow, clearing the cache did not help either. wonder why. but any how, it works now.
so after a lot of trouble shooting, got to know that the node versions were different and conflicting. in the terminal, though the node version was the latest, some of the files of node older version were not deleted and hence got this error while npm install. so deleted the files manually, uninstalled latest version of node. reinstalled it. after doing npm install --force, i got to know about the version mess. somehow, clearing the cache did not help either. wonder why. but any how, it works now.