无法安装最新版本的nodejs。我尝试安装nodejs 17.x

问题描述 投票:0回答:4

我正在尝试安装nodejs 17.x,但最终安装了nodejs 10.19。 |操作系统:Ubuntu 20.04.4 LTS x86_64 |贝壳:鱼壳
请帮助...我需要为我的项目安装最新版本的 npm 但由于这个问题我陷入困境:(
我认为卷曲工作不正常。我是菜鸟,对linux不太了解。

    $ cd ~
    $ curl -sL https://deb.nodesource.com/setup_17.x -o nodesource_setup.sh
    
    $ sudo bash nodesource_setup.sh

    ## Installing the NodeSource Node.js 17.x repo...
    
    
    ## Populating apt-get cache...
    
    + apt-get update
    Ign:1 https://repo.nordvpn.com/deb/nordvpn/debian stable InRelease
    Hit:2 http://dl.winehq.org/wine-builds/ubuntu focal InRelease                                                                                                                          
    Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease                                                                                                                              
    Err:4 https://repo.nordvpn.com/deb/nordvpn/debian stable Release                                                                                                                       
      Could not handshake: Error in the pull function. [IP: 104.17.49.74 443]
    Hit:5 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease                                                                                                                      
    Get:6 http://repo.mysql.com/apt/ubuntu focal InRelease [12.9 kB]                                                                                                                       
    Get:7 https://packages.microsoft.com/repos/edge stable InRelease [7,342 B]                                                                                                             
    Hit:8 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease                                                                                                               
    Hit:9 http://ppa.launchpad.net/audio-recorder/ppa/ubuntu focal InRelease                                                                       
    Hit:10 https://deb.opera.com/opera-stable stable InRelease                                                                     
    Get:11 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                                                     
    Err:6 http://repo.mysql.com/apt/ubuntu focal InRelease                                                               
      The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
    Err:7 https://packages.microsoft.com/repos/edge stable InRelease                                                     
      The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
    Hit:12 http://ppa.launchpad.net/ethereum/ethereum/ubuntu focal InRelease                                             
    Hit:13 http://ppa.launchpad.net/fish-shell/release-3/ubuntu focal InRelease                                          
    Hit:14 http://ppa.launchpad.net/gencfsm/ppa/ubuntu focal InRelease                 
    Hit:15 https://dl.google.com/linux/chrome/deb stable InRelease                     
    Reading package lists... Done   
    E: The repository 'https://repo.nordvpn.com/deb/nordvpn/debian stable Release' does not have a Release file.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mysql.com/apt/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 467B942D3A79BD29
    W: GPG error: https://packages.microsoft.com/repos/edge stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
    E: The repository 'https://packages.microsoft.com/repos/edge stable InRelease' is not signed.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    Error executing command, exiting
    
    $ sudo apt install nodejs
    
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      cmake-data libevent-2.1-7 libjsoncpp1 libnatpmp1 librhash0 transmission-common
    Use 'sudo apt autoremove' to remove them.
    Suggested packages:
      npm
    The following NEW packages will be installed:
      nodejs
    0 upgraded, 1 newly installed, 0 to remove and 24 not upgraded.
    Need to get 0 B/61.1 kB of archives.
    After this operation, 158 kB of additional disk space will be used.
    Selecting previously unselected package nodejs.
    (Reading database ... 284202 files and directories currently installed.)
    Preparing to unpack .../nodejs_10.19.0~dfsg-3ubuntu1_amd64.deb ...
    Unpacking nodejs (10.19.0~dfsg-3ubuntu1) ...
    Setting up nodejs (10.19.0~dfsg-3ubuntu1) ...
    update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
    Processing triggers for man-db (2.9.1-1) ...
    
    $ node -v
    
    v10.19.0
node.js ubuntu npm curl apt
4个回答
1
投票

我建议您使用nvm来安装和管理node.js版本。

要在 Ubuntu 上安装 nvm 查看文档的这一部分

然后很容易安装/切换不同版本的node。


# nvm install <node_version>
$ nvm install 12

# nvm use <node_version>
$ nvm use 12


0
投票

这也发生在我身上。我遵循此处的建议https://askubuntu.com/questions/1141035/error-executing-command-exiting

# Remove the current installed nodejs
sudo apt-get purge nodejs*

# Remove every other apt sources
sudo rm -rf /var/lib/apt/lists/* 
sudo rm -rf /etc/apt/sources.list.d/* 
sudo apt-get update 

# Add the nodejs repository again
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -  
sudo apt-get install -y nodejs

0
投票

使用 nvm 节点安装程序,这是最好、最简单的方法。

  1. 在终端中执行此操作
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  1. 像这样更新配置文件配置
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  1. 重新加载外壳
source ~/.bashrc
  1. 像这样安装和使用节点
nvm install 18
nvm use 18
  1. 再次重新加载shell并通过node -v进行检查。

谢谢。


-1
投票

您是否尝试过先拉取最新更新?尝试

sudo apt -y update && sudo apt -y upgrade
curl -sL https://deb.nodesource.com/setup_17.x | sudo bash -
sudo apt-get install -y nodejs

如果这有效的话! 附注sudo 就像 Windows 中的管理员用户。您还需要有超级用户密码!

© www.soinside.com 2019 - 2024. All rights reserved.