【问题标题】:Uninstall node from /usr/local/bin/node从 /usr/local/bin/node 卸载节点
【发布时间】:2020-04-13 20:51:38
【问题描述】:

我在卸载一个甚至不存在但仍显示在路径中的包 node 时遇到问题,这很奇怪,还是我很笨... 它与 nodejs 相矛盾,我想摆脱它并安装一个新的 node 符号链接到 nodejs 以便我有一个单一的事实来源。 到目前为止,我已经尝试了大多数流行的包管理器。

#tag node vs nodejs linux

durrani@ideapad:~ $ nodejs --version
Command 'nodejs' not found, but can be installed with:
sudo apt install nodejs

durrani@ideapad:~ $ node --version
v12.14.0
durrani@ideapad:~ $ which nodejs
durrani@ideapad:~ $ which node   
/usr/local/bin/node
durrani@ideapad:~ $ type node
node is hashed (/usr/local/bin/node)
durrani@ideapad:~ $ type nodejs
bash: type: nodejs: not found
durrani@ideapad:~ $ sudo apt-get remove node
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package node
durrani@ideapad:~ $ sudo apt-get purge node
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package node
durrani@ideapad:~ $ sudo snap remove node
snap "node" is not installed
durrani@ideapad:~ $ sudo pkcon remove node
Resolving                     [=========================]         Package not found: node
Command failed: This tool could not find the installed package: No packages were found

【问题讨论】:

    标签: node.js linux ubuntu apt nvm


    【解决方案1】:

    this 获得一些帮助并运行以下命令:

    sudo rm -rf /usr/local/bin/npm
    sudo rm -rf /usr/local/bin/node
    sudo rm -rf /usr/local/lib/node_modules/
    sudo rm -rf /usr/local/include/node/
    sudo rm -rf /usr/local/share/man/man1/node.1
    

    然后我使用Node.js网站上提到的官方方法安装了nodejs -> instructions

    TL;DR 运行以下命令:
    12.16.2 是今天的 LTS 版本。

    curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
    sudo apt-get install -y nodejs
    

    我得到的最终结果:

    durrani@ideapad:~ $ node --version
    v12.16.2
    durrani@ideapad:~ $ nodejs --version
    v12.16.2
    durrani@ideapad:~ $ which node
    /usr/bin/node
    durrani@ideapad:~ $ which nodejs
    /usr/bin/nodejs
    

    【讨论】:

    • 该说明也适用于更新版本。非常感谢。
    猜你喜欢
    • 2015-02-22
    • 2019-01-15
    • 2014-09-26
    • 2016-08-30
    • 2011-02-05
    • 2020-03-30
    • 2013-04-22
    • 2021-03-25
    • 2013-09-18
    相关资源
    最近更新 更多