node.js - sudo apt-get install npm 未安装

标签 node.js ubuntu npm npm-install

我尝试运行 sudo apt-get install npm 它返回下面的对话。我该如何解决这个问题?

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
npm : Depends: node-gyp (>= 0.10.9) but it is not going to be 
installed
E: Unable to correct problems, you have held broken packages.

最佳答案

npm 与 nodejs 一起安装。如果您安装了 Node ,那么您也安装了 npm。

运行 node -v 检查是否安装了 node,然后运行 ​​npm -v 为 npm 做同样的事情。

如果没有安装 nodejs,请在此处查看安装说明: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

6.x 是当前的稳定分支。

通常,要运行删除现有 Node/npm 安装并从头开始安装,请运行:

sudo apt remove --purge nodejs node npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove

关于node.js - sudo apt-get install npm 未安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46315762/

相关文章:

performance - Node.js - 将 pipeline() 发送到 http 响应会导致 ubuntu 上的响应时间变慢

javascript - 如何使用 .node 文件?

javascript - 为什么 npm 看不到类星体?

linux - 主进程退出,code=exited,status=203/EXEC

npm - 构建成功运行 `next build` 时,AWS CodeBuild 不生成任何工件

javascript - 我如何在 node.js 中搜索?

node.js - Node 部署失败: New Azure Site

node.js - 如何在 node 中集成 swagger 和 fastify 框架

node.js - 使用 mongoose 在数组字段的对象中查找匹配项

javascript - 在 ubuntu 的 Ionic 框架中添加 Android 平台时出错