node.js - 在 Ubuntu 16.04 中卸载 npm 后无法安装 npm

标签 node.js ubuntu npm-install

由于一些问题,我使用此命令完全卸载了 npm。
“sudo apt-get purge --auto-remove npm”
现在,当我尝试使用“sudo apt-get install npm”再次安装 npm 时,出现以下错误:

The following packages have unmet dependencies:
 npm : Depends: nodejs but it is not going to be installed
       Depends: node-abbrev (>= 1.0.4) but it is not going to be installed
       Depends: node-ansi (>= 0.3.0-2) but it is not going to be installed
       Depends: node-ansi-color-table but it is not going to be installed
       Depends: node-archy but it is not going to be installed
       Depends: node-block-stream but it is not going to be installed
       Depends: node-fstream (>= 0.1.22) but it is not going to be installed
       Depends: node-fstream-ignore but it is not going to be installed
       Depends: node-github-url-from-git but it is not going to be installed
       Depends: node-glob (>= 3.1.21) but it is not going to be installed
       Depends: node-graceful-fs (>= 2.0.0) but it is not going to be installed
       Depends: node-inherits but it is not going to be installed
       Depends: node-ini (>= 1.1.0) but it is not going to be installed
       Depends: node-lockfile but it is not going to be installed
       Depends: node-lru-cache (>= 2.3.0) but it is not going to be installed
       Depends: node-minimatch (>= 0.2.11) but it is not going to be installed
       Depends: node-mkdirp (>= 0.3.3) but it is not going to be installed
       Depends: node-gyp (>= 0.10.9) but it is not going to be installed
       Depends: node-nopt (>= 3.0.1) but it is not going to be installed
       Depends: node-npmlog but it is not going to be installed
       Depends: node-once but it is not going to be installed
       Depends: node-osenv but it is not going to be installed
       Depends: node-read but it is not going to be installed
       Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed
       Depends: node-request (>= 2.25.0) but it is not going to be installed
       Depends: node-retry but it is not going to be installed
       Depends: node-rimraf (>= 2.2.2) but it is not going to be installed
       Depends: node-semver (>= 2.1.0) but it is not going to be installed
       Depends: node-sha but it is not going to be installed
       Depends: node-slide but it is not going to be installed
       Depends: node-tar (>= 0.1.18) but it is not going to be installed
       Depends: node-underscore but it is not going to be installed
       Depends: node-which but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我尝试使用

“sudo apt-get install -f npm”和“sudo apt-get install aptitude npm”
但是得到同样的错误......

最佳答案

你有安装 NodeJS 吗?它还安装 npm。

尝试安装它:

sudo apt-get install nodejs

要检查之后是否安装了 npm,请输入 npm --version

关于node.js - 在 Ubuntu 16.04 中卸载 npm 后无法安装 npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42131251/

相关文章:

javascript - NodeJS 和 MySQL 中标记系统的 3 个表更新的最佳方法

node.js - 手动安装全局依赖

c++ - 如何安装opencv4nodejs模块

ubuntu - Terraform 数据源 DataSource 无 Ubuntu 20.04

ubuntu - 在 ubuntu 15.10 上快速构建错误

javascript - 在生产中,我应该在每次部署时清理并重新安装 node_modules 吗?

node.js - 如何修复 npm 无法全局安装 typescript 错误

javascript - MongoDB 对大容量数据进行排序

c++ - Ubuntu下没有libmongoclient.a

npm - 如何通过 npm 安装测试版