E: Unable to locate package npm

后端 未结 10 2440
耶瑟儿~
耶瑟儿~ 2020-12-07 18:08

When I try to install npm with sudo apt-get install npm, I got following error:

E: Unable to locate package npm

Why

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 19:04

    Your system can't find npm package because you haven't add nodejs repository to your system..

    Try follow this installation step:
    Add nodejs PPA repository to our system and python software properties too

    sudo apt-get install curl python-software-properties 
    // sudo apt-get install curl software-properties-common
    
    curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
    sudo apt-get update
    

    Then install npm

    sudo apt-get install nodejs
    

    Check if npm and node was installed and you're ready to use node.js

    node -v
    npm -v
    

    If someone was failed to install nodejs.. Try remove the npm first, maybe the old installation was broken..

    sudo apt-get remove nodejs
    sudo apt-get remove npm
    

    Check if npm or node folder still exist, delete it if you found them

    which node
    which npm
    

提交回复
热议问题