Skip to content
Advertisement

Node error Cannot read property ‘resolve’ of undefined

I am using reactjs and am unable to install any packages using npm install. The error message I’m getting is :

JavaScript

When I do npm install -verbose:

JavaScript

I am not even able to uninstall npm and reinstall it as I am getting the same error when I try to uninstall. What is the issue here and how do I fix it?

Advertisement

Answer

The reason for the error was probably conflicting global packages and node versions. I uninstalled node and npm and then reinstalled them.

To remove nodejs and associated packages (like npm):

JavaScript

Nodejs and npm will leave files in the system which may cause issues during reinstallation. I had to remove them as well.

Although it is a bad practice to remove packages manually (it may cause problems with the package manager), it helped my case. This answer shows how to remove nodejs and related files manually.

To reinstall them:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement