NPM:Debian 9.13 Stretch 上未满足的依赖关系

NPM:Debian 9.13 Stretch 上未满足的依赖关系

我正在尝试在运行 Debian 9.13 Stretch 的 Google Cloud Platform Debian 实例上安装 NPM。但是,如果我尝试使用$ sudo apt install 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 (>= 6.11~) but 4.8.2~dfsg-1 is to be installed                                                                                                                
       Depends: node-abbrev (>= 1.1.1~) but 1.0.9-1 is to be installed                                                                                                               
       Depends: node-ansi-regex (>= 3.0~) but 2.0.0-1 is to be installed                                                                                                             
       Depends: node-cacache (>= 10.0.4~) but it is not going to be installed                                                                                                        
       Depends: node-config-chain (>= 1.1.11~) but it is not going to be installed                                                                                                   
       Depends: node-glob (>= 7.1.2~) but 7.1.1-1 is to be installed                                                                                                                 
       Depends: node-hosted-git-info (>= 2.6~) but 2.1.5-1 is to be installed                                                                                                        
       Depends: node-ini (>= 1.3.5~) but 1.1.0-1+deb9u1 is to be installed                                                                                                           
       Depends: node-npm-package-arg but it is not going to be installed                                                                                                             
       Depends: node-jsonstream (>= 1.3.2~) but 1.0.3-4 is to be installed                                                                                                           
       Depends: node-libnpx (>= 10.0.1~) but it is not going to be installed                                                                                                         
       Depends: node-lockfile (>= 1.0.3~) but 0.4.1-1 is to be installed                                                                                                             
       Depends: node-lru-cache (>= 4.1.1~) but 4.0.2-1 is to be installed                                                                                                            
       Depends: node-move-concurrently (>= 1.0.1~) but it is not going to be installed                                                                                               
       Depends: node-normalize-package-data (>= 2.4~) but 2.3.5-2 is to be installed                                                                                                 
       Depends: node-gyp (>= 3.6.2~) but 3.4.0-1 is to be installed                                                                                                                  
       Depends: node-resolve-from (>= 4.0~) but 2.0.0-1 is to be installed                                                                                                           
       Depends: node-npmlog (>= 4.1.2~) but 0.0.4-1 is to be installed                                                                                                               
       Depends: node-osenv (>= 0.1.5~) but 0.1.0-1 is to be installed                                                                                                                
       Depends: node-read-package-json (>= 2.0.13~) but 1.2.4-1 is to be installed                                                                                                   
       Depends: node-request (>= 2.83~) but 2.26.1-1 is to be installed                                                                                                              
       Depends: node-retry (>= 0.10.1~) but 0.6.0-1 is to be installed                                                                                                               
       Depends: node-rimraf (>= 2.6.2~) but 2.5.4-2 is to be installed                                                                                                               
       Depends: node-semver (>= 5.5~) but 5.3.0-1 is to be installed                                                                                                                 
       Depends: node-sha (>= 2.0.1~) but 1.2.3-1 is to be installed                                                                                                                  
       Depends: node-slide (>= 1.1.6~) but 1.1.4-1 is to be installed                                                                                                                
       Depends: node-strip-ansi (>= 4.0~) but 3.0.1-1 is to be installed                                                                                                             
       Depends: node-tar (>= 4.4~) but 2.2.1-1 is to be installed                                                                                                                    
       Depends: node-boxen (>= 1.2.1~) but it is not going to be installed                                                                                                           
       Depends: node-latest-version (>= 3.0~) but it is not going to be installed                                                                                                    
       Depends: node-which (>= 1.3~) but 1.2.11-1 is to be installed                                                                                                                 
E: Unable to correct problems, you have held broken packages.

我使用默认源列表,并尝试$sudo apt install -f npm多次运行sudo apt update标准命令来查找问题。有什么想法吗?也找不到此问题的错误报告。

编辑:输出sudo apt-cache policy npm

\npm:                                                                                                                                                                                
  Installed: (none)                                                                                                                                                                  
  Candidate: 5.8.0+ds6-2~bpo9+1                                                                                                                                                      
  Version table:                                                                                                                                                                     
     5.8.0+ds6-2~bpo9+1 100                                                                                                                                                          
        100 http://deb.debian.org/debian stretch-backports/main amd64 Packages 

答案1

npm有点不寻常的情况是,仅在 Stretch 向后移植中可用,而不是在主要的 Debian 9 存储库中可用,同时还需要来自向后移植的其他软件包。因为后者不是默认安装候选者,所以您需要告诉apt考虑它们:

sudo apt install -t stretch-backports npm

答案2

节点可用作为一个snap:

sudo apt install snapd 
sudo snap refresh node --channel=15
sudo snap install node --classic --channel=15

并且还有一个独立的存储库;使用安装脚本:

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

相关内容