【问题标题】:Having issues installing nodejs/npm安装 nodejs/npm 时遇到问题
【发布时间】:2017-07-05 10:36:48
【问题描述】:

我已经完全卸载了 nodejs/npm。

但是,他们似乎在安装时始终抛出相同的错误。 我也试过 sudo-apt get update sudo apt cache verify 和 apt cache search,当我搜索 nodejs 时找不到或 npm。

The program 'nodejs' is currently not installed. You can install it by typing:
sudo apt-get install nodejs

当我执行 sudo apt-get intall nodejs

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package nodejs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'nodejs' has no installation candidate

我已确保 nodejs/npm 已从 /usr/bin 等中删除。似乎仍然无法正常工作。

【问题讨论】:

    标签: node.js npm installation


    【解决方案1】:

    尝试apt-get update更新列表。

    【讨论】:

      【解决方案2】:

      试试

      这将通过在命令行键入以下内容来安装节点版本管理器 (nvm)。 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash

      然后通过在命令行中键入以下内容来激活 nvm。 . ~/.nvm/nvm.sh

      然后使用 nvm 通过在命令行中键入以下内容来安装您打算使用的 Node.js 版本。 nvm install 4.4.5(比如可以安装6.1.0 LTS)

      然后通过键入来测试它 node -e "console.log('Running Node.js ' + process.version)"

      【讨论】:

      • 运行nodejs,是命令行还是node运行nodejs?它们是一样的吗?
      • 在cli上你需要输入node
      • 我还为 NPM 做什么?
      • 是的,它们是同一个东西,通常人们将 node.js 称为 node 或 nodejs 只是为了简称它的名字。就像有些人将 react.js 称为 react 或 reactjs 一样。在 cli 上,它是 node 默认创建的别名。
      • Node 默认安装 npm。不过,您可以通过输入 npm install npm@latest -g 来更新 npm
      【解决方案3】:

      从官方 Ubuntu 存储库安装 NPM 和 Node.js。 首先,使用 ssh 连接到您的服务器: ssh username @ server_ip_address 连接后,刷新 APT 缓存:sudo apt update Node.js 设置:sudo apt install nodejs 您还可以安装 NPM,即 Node.js 包管理器:sudo apt install npm 最后检查安装的版本:nodejs -v 要删除 node.js,请运行以下命令:sudo apt remove nodejs

      【讨论】:

        猜你喜欢
        • 2012-08-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-24
        • 2017-10-25
        • 1970-01-01
        • 2014-09-11
        • 2013-12-24
        相关资源
        最近更新 更多