无法在Ubuntu 16.04 LTS(64位)上安装NodeJS 9

时间:2018-02-14 20:42:21

标签: node.js linux ubuntu

我尝试使用以下命令安装NodeJS:

sudo apt-get install nodejs

问题是,它安装了旧版本的NodeJS。所以我找到了另一种方法来通过以下命令安装更新版本的NodeJS:

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -

但它不断向我发出以下错误消息:

adam@adam-pc:~$ curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -

## Installing the NodeSource Node.js v9.x repo...


## Populating apt-get cache...

+ apt-get update
Get:1 http://hu.archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Hit:2 http://ppa.launchpad.net/git-core/ppa/ubuntu xenial InRelease                                                     
Get:3 http://hu.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]                                             
Ign:4 http://dl.google.com/linux/chrome/deb stable InRelease                                                            
Get:5 http://hu.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]                                           
Hit:6 http://ppa.launchpad.net/linrunner/tlp/ubuntu xenial InRelease                                                    
Hit:7 http://dl.google.com/linux/chrome/deb stable Release                                                              
Ign:8 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial InRelease                                         
Hit:9 http://security.ubuntu.com/ubuntu xenial-security InRelease                                  
Hit:10 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease                 
Ign:11 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial Release
Ign:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons
Ign:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons
Ign:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons
Ign:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons
Ign:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons
Err:12 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 Packages
  404  Not Found
Ign:13 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main i386 Packages
Ign:14 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main all Packages
Ign:15 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en_US
Ign:16 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main Translation-en                              
Ign:17 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main amd64 DEP-11 Metadata                       
Ign:18 http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial/main DEP-11 64x64 Icons                          
Fetched 451 kB in 6s (70,4 kB/s)                                                                                        
Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/michael-gruz/canon-trunk/ubuntu/dists/xenial/main/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Error executing command, exiting

我现在一直在寻找解决方案几个小时,尝试了StackOverflow和我在谷歌上发现的不同论坛的10个想法,但仍然没有。

修改

同时我找到了解决方案。

我通过以下命令打开了Ubuntu Update manager

update-manager

然后我点击了SettingsOther software标签,并取消了我发现的所有http://ppa.launchpad.net/内容,这些内容都是我发现的(尤其是所有michael-gruz链接)。

然后再次使用上面的命令:

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install nodejs

现在我安装了v9.5.0

2 个答案:

答案 0 :(得分:2)

安装命令本身没有任何问题。如果您要查看它出错的原因,您可以看到启动板包已经过了404.如果删除此存储库,它将不会中断apt并允许安装包。您应该能够删除此删除的PPA,如下所示:

sudo add-apt-repository --remove ppa:michael-gruz/ppa

答案 1 :(得分:1)

我建议为节点使用版本管理器。最受欢迎的是nvmn

现在你可以:

sudo apt-get install nodejs // install a really old node
npm install n -g // get n
n latest // get latest node, or a specific one with n v8.0.0