Node error Cannot read property 'resolve' of undefined

前端 未结 8 2532
遇见更好的自我
遇见更好的自我 2021-02-18 23:28

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

npm ERR! Cannot read property \'reso         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-19 00:08

    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):

    sudo apt-get purge --auto-remove nodejs
    

    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:

    sudo apt-get update
    sudo apt-get install nodejs
    sudo apt-get install npm
    

提交回复
热议问题