【问题标题】:bash: npm: command not found after installing nodejs on Linux [duplicate]bash:npm:在Linux上安装nodejs后找不到命令[重复]
【发布时间】:2018-05-03 13:53:26
【问题描述】:

我要安装https://github.com/kangax/html-minifier

但在使用npm install html-minifier 后,我收到消息:

bash: npm: command not found

我正在使用 Debian 9 拉伸并通过 apt-get install 获得了 nodejs。 我试图通过安装 nodejs-legacy 和 build-essential 来解决我的问题,但没有任何改变。 如果我使用nodejs -v,我会得到v4.8.2。 之前没用过nodejs,怎么了?

【问题讨论】:

    标签: node.js linux bash npm npm-install


    【解决方案1】:

    尝试使用“sudo apt-get install npm”安装 npm,它应该可以工作。您也可以通过 nvm (https://github.com/creationix/nvm) 安装 node js。

    它会自动为你安装 npm。

    【讨论】:

    • 运行 sudo apt-get install npm 得到我:Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package npm
    • 你能尝试通过 NVM 安装吗?运行'curl -o- raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash' 来安装 nvm。安装 nvm 后,您可以通过运行“nvm install v8.9.1”来安装节点 js。重新加载 .bashrc 后,npm 应该可以工作了。
    • 现在我已经安装了 npm。我很愚蠢 npm 不属于官方的 debian 包。我安装了它:curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -sudo apt-get install -y nodejs
    猜你喜欢
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 2017-03-05
    • 2018-06-05
    • 2018-08-03
    • 1970-01-01
    • 2018-02-18
    • 2016-03-06
    相关资源
    最近更新 更多