npm 安装错误

npm 安装错误

当我在安装 nodejs 后安装 npm 时

best@ubuntu:~$ sudo apt-get install npm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
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: nodejs but it is not going to be installed
       Depends: nodejs-dev
       Depends: node-request but it is not going to be installed
       Depends: node-mkdirp but it is not going to be installed
       Depends: node-minimatch but it is not going to be installed
       Depends: node-semver but it is not going to be installed
       Depends: node-ini but it is not going to be installed
       Depends: node-graceful-fs but it is not going to be installed
       Depends: node-abbrev but it is not going to be installed
       Depends: node-nopt but it is not going to be installed
       Depends: node-fstream but it is not going to be installed
       Depends: node-rimraf but it is not going to be installed
       Depends: node-tar 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.
best@ubuntu:~$ npm -v
1.4.28
best@ubuntu:~$ nodejs -v
v0.10.40
best@ubuntu:~$ 

我不知道为什么安装 npm 后以下命令无法正确安装,并且无法保存损坏的包。

sudo npm install -g less-plugin-clean-css
sudo npm install -g less

还有一件事当我应用以下命令时

sudo apt-cache policy nodejs npm

它给了我以下输出

nodejs:
  Installed: 0.10.40-1nodesource1~precise1
  Candidate: 0.10.40-1nodesource1~precise1
  Version table:
 *** 0.10.40-1nodesource1~precise1 0
        500 https://deb.nodesource.com/node_0.10/ precise/main i386 Packages
        100 /var/lib/dpkg/status
     0.10.37-1chl1~precise1 0
        500 http://ppa.launchpad.net/chris-lea/node.js/ubuntu/ precise/main i386 Packages
     0.6.12~dfsg1-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/universe i386 Packages
npm:
  Installed: (none)
  Candidate: 1.1.4~dfsg-1
  Version table:
     1.1.4~dfsg-1 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise/universe i386 Packages

答案1

安装以下软件包nodejs节点源npm已经安装。

在官方的 Ubuntu 存储库中,有两个单独的包和npmnodejs并且npm依赖于nodejs,因此造成混淆。

简单开始

sudo apt-get install -f

修复您的系统,如果有需要修复的东西,请忽略并且不要安装该软件包npm


因为我刚刚也在你的问题中读到了这一点

0.10.37-1chl1~precise1 0
   500 http://ppa.launchpad.net/chris-lea/node.js/ubuntu/ precise/main i386 Packages

如果你使用 PPA,同样适用ppa:克里斯-利亚/node.js

相关内容