我遵循了这个要点https://gist.github.com/Goddard/5500157安装 nodejs 和 npm,但运行后 node --version 和 npm --version 都无法运行,并显示命令未找到的错误。我可以卸载 nodejs,但必须进入脚本中描述的临时目录并执行 make uninstall 才能让 npm 退出。
现在,为了再次尝试安装 nodejs 和 npm,我改用了这个链接http://www.andreagrandi.it/2013/02/08/how-to-install-latest-stable-node-js-on-ubuntu/,但如果我尝试同时安装 nodejs 和 npm,我会收到此错误消息。
sudo apt-get install nodejs npm
The following packages have unmet dependencies:
nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.
如果我仅安装 nodejs,它就可以正常工作。
sudo apt-get install nodejs
node --version
v0.10.15
但是现在如果我尝试安装 npm,它会给出这个错误消息
sudo apt-get install npm
The following packages have unmet dependencies:
npm : Depends: nodejs (>= 0.6.19~dfsg1-3) but it is not going to be installed
Depends: nodejs-dev
Depends: node-node-uuid but it is not going to be installed
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.
我正在使用 Ubuntu 13.04。任何帮助都非常感谢。我对 node.js 和 npm 了解不多。我正试图开始学习如何使用它们,所以我的经验不足可能已经显现出来了。
答案1
nodejs
您从 PPA 安装的软件包包含自npm
v0.10.0 以来的版本。由于您拥有 v0.10.15,因此当您运行时sudo apt-get install nodejs
您还安装了npm
。尝试运行npm
以确认。
另请参阅官方安装指南(您遵循的版本是它的副本,但官方版本有一些额外的细节)。