use*_*351 43 package-management nodejs npm
尝试在 ubuntu 12.04 上安装 nodejs 和 npm。我用谷歌搜索并做到了。现在,我无法在机器上安装 npm。
sudo apt-get install npm
Run Code Online (Sandbox Code Playgroud)
这给了我这个
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.
Run Code Online (Sandbox Code Playgroud)
Mar*_*ppi 39
看起来您可能安装了chris-lea node.js ppa,这很好。但是,您不要从该 ppa 安装 npm,因为它破坏了 debian 软件包的工作方式。相反,只需安装nodejs
. 安装完成后,运行npm -v
您应该看到它现在已安装。如果您没有使用 chris-lea ppa,请在您通过 Google 搜索的网页上更新您的问题,以了解如何在 Ubuntu 上安装 nodejs。
尝试像这样安装 NodeJ:
sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)
由于 NodeJs 安装了 node 和 npm
我按照此文档解决了这个问题。
使用 npm 时需要记住的提示:
mkdir ~/nodejs/ && cd ~/nodejs
sudo apt-get install npm
npm install
npm update
Run Code Online (Sandbox Code Playgroud)
在开发应用程序时,如果nodejs需要任何特定模块,则运行
cd ~/nodejs
npm install modulename #for example sendgrid
Run Code Online (Sandbox Code Playgroud)
有时,模块需要全局安装;然后使用
sudo npm install modulename -g"
Run Code Online (Sandbox Code Playgroud)
要删除模块:
cd ~/nodejs
npm uninstall modulename # if locally installed or
sudo npm uninstall modulename -g # if globally installed
Run Code Online (Sandbox Code Playgroud)
npm prune
有助于消除未满足的依赖关系