node.js - 如何在 Linux 上安装 node.js 和 npm?

标签 node.js linux ubuntu

我正在学习一门类(class)的教程,在它的特定步骤中,我应该使用这些特定说明安装 node 和 node.js。

enter image description here

但我对第一步感到困惑。我不明白如何在终端中输入它。什么是<<EOL ?有人可以解释一下或将其显示为 1 衬里,以便我可以使用它。我尝试只复制粘贴它,但随后在安装 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: 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.

谢谢

最佳答案

只需使用我推荐的 Node 版本管理器 (nvm)。

https://github.com/creationix/nvm

安装 nvm 后运行 nvm install 6.9.4 或任何你想要的版本。然后运行nvm alias default 6.9.4

关于node.js - 如何在 Linux 上安装 node.js 和 npm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47192037/

相关文章:

ubuntu - 使用现有的 Nginx 安装转发到 GitLab 子域

javascript - 为什么 ISO 日期转换在 javascript 环境中不一致以及如何修复?

python - 永远防止启动重复进程

javascript - 将附加参数传递给 Node js 中 fs.readFile 的回调

c - copy_from_user是否修改用户指针?

linux - 尝试获取 token 时 Xero Partner API Oauth 证书问题 (Linux/Perl)

windows - 登录到适用于 Linux 的 Windows 子系统时如何自动运行命令

javascript - Node 加密解密流抛出 EVP_DecryptFinal_ex :wrong final block length if stream will be interrupted

linux - 期望发送SSH

通过 Internet 连接时,Apache 尝试连接到本地网络