Debian

如何在我的 debian 上安裝 npm?

  • July 12, 2020

nodejs安裝在我的 debian 上。

nodejs -v
v4.8.2

用同樣的方法,我想安裝npm

sudo aptitude install -f npm

 The following NEW packages will be installed:
 libjs-inherits{a} node-abbrev{a} node-ansi{a} node-ansi-align{a} 
 node-ansi-regex{a} node-ansistyles{a} node-aproba{a} node-archy{a} 
 node-balanced-match{a} node-bluebird{a} node-boxen{ab} 
 node-brace-expansion{a} node-builtins{a} node-cacache{ab} 
 node-call-limit{a} node-chownr{a} node-cli-boxes{a} node-clone{a} 
 node-concat-map{a} node-concat-stream{a} node-config-chain{ab} 
 node-copy-concurrently{ab} node-cross-spawn{a} node-cross-spawn-async{a} 
 node-cyclist{a} node-decompress-response{a} node-deep-extend{a} 
 node-defaults{a} node-detect-indent{a} node-detect-newline{a} 
 node-duplexer3{a} node-duplexify{a} node-editor{a} node-encoding{a} 
 node-end-of-stream{a} node-errno{a} node-execa{a} 
 node-flush-write-stream{a} node-from2{a} node-fs-vacuum{a} 
 node-fs-write-stream-atomic{a} node-fs.realpath{a} node-get-stream{a} 
 node-glob{a} node-got{a} node-graceful-fs{a} node-has-symbol-support-x{a} 
 node-has-to-string-tag-x{a} node-has-unicode{a} node-iconv-lite{a} 
 node-iferr{a} node-import-lazy{a} node-imurmurhash{a} node-inflight{a} 
 node-inherits{a} node-ini{a} node-is-npm{a} node-is-object{a} 
 node-is-plain-obj{a} node-is-retry-allowed{a} node-is-stream{a} 
 node-isexe{a} node-isurl{a} node-json-parse-better-errors{a} 
 node-latest-version{a} node-lazy-property{a} node-libnpx{ab} 
 node-lowercase-keys{a} node-lru-cache{a} node-mimic-response{a} 
 node-minimatch{a} node-minimist{a} node-mississippi{a} node-mkdirp{a} 
 node-move-concurrently{ab} node-mute-stream{a} node-nopt{a} 
 node-npm-package-arg{ab} node-npm-run-path{a} node-once{a} node-opener{a} 
 node-p-cancelable{a} node-p-finally{a} node-p-timeout{a} 
 node-package-json{a} node-parallel-transform{a} node-path-is-absolute{a} 
 node-path-is-inside{a} node-prepend-http{a} node-promise-inflight{a} 
 node-promzard{a} node-proto-list{a} node-prr{a} node-pseudomap{a} 
 node-pump{a} node-pumpify{a} node-qw{a} node-rc{a} node-read{a} 
 node-registry-auth-token{a} node-registry-url{a} node-rimraf{a} 
 node-run-queue{a} node-safe-buffer{a} node-semver{a} node-semver-diff{a} 
 node-signal-exit{a} node-sorted-object{a} node-ssri{a} 
 node-stream-each{a} node-stream-iterate{a} node-stream-shift{a} 
 node-string-width{a} node-strip-ansi{a} node-strip-eof{a} 
 node-strip-json-comments{a} node-term-size{a} node-text-table{a} 
 node-through2{a} node-timed-out{ab} node-typedarray{a} node-uid-number{a} 
 node-unique-filename{a} node-unpipe{a} node-url-parse-lax{a} 
 node-url-to-options{a} node-validate-npm-package-name{a} 
 node-wcwidth.js{a} node-which{a} node-widest-line{a} node-wrappy{a} 
 node-write-file-atomic{a} node-xdg-basedir{a} node-xtend{a} node-y18n{a} 
 node-yallist{a} npm{b} 
0 packages upgraded, 137 newly installed, 0 to remove and 30 not upgraded.
Need to get 1,910 kB of archives. After unpacking 12.4 MB will be used.
The following packages have unmet dependencies:
node-boxen : Depends: node-camelcase (>= 4.0.0) but it is not going to be installed
             Depends: node-chalk (>= 2.0.1) but it is not going to be installed
node-timed-out : Depends: nodejs (>= 6) but 4.8.2~dfsg-1 is installed
node-copy-concurrently : Depends: node-mkdirp (>= 0.5.1) but 0.5.0-1 is to be installed
node-npm-package-arg : Depends: node-hosted-git-info (>= 2.5~) but it is not going to be installed
                       Depends: node-osenv (>= 0.1.4~) but it is not going to be installed
                       Depends: node-semver (>= 5.4.1~) but 5.3.0-1 is to be installed
node-move-concurrently : Depends: nodejs (>= 8~) but 4.8.2~dfsg-1 is installed
                         Depends: node-mkdirp (>= 0.5.1) but 0.5.0-1 is to be installed
npm : Depends: nodejs (>= 6.11~) but 4.8.2~dfsg-1 is 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-glob (>= 7.1.2~) but 7.1.1-1 is to be installed
      Depends: node-hosted-git-info (>= 2.6~) but it is not going to be installed
      Depends: node-ini (>= 1.3.5~) but 1.1.0-1 is to be installed
      Depends: node-jsonstream (>= 1.3.2~) but it is not going to be installed
      Depends: node-lockfile (>= 1.0.3~) but it is not going to be installed
      Depends: node-lru-cache (>= 4.1.1~) but 4.0.2-1 is to be installed
      Depends: node-normalize-package-data (>= 2.4~) but it is not going to be installed
      Depends: node-gyp (>= 3.6.2~) but it is not going to be installed
      Depends: node-resolve-from (>= 4.0~) but it is not going to be installed
      Depends: node-npmlog (>= 4.1.2~) but it is not going to be installed
      Depends: node-osenv (>= 0.1.5~) but it is not going to be installed
      Depends: node-read-package-json (>= 2.0.13~) but it is not going to be installed
      Depends: node-request (>= 2.83~) but it is not going to be installed
      Depends: node-retry (>= 0.10.1~) but it is not going 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 it is not going to be installed
      Depends: node-slide (>= 1.1.6~) but it is not going to be installed
      Depends: node-strip-ansi (>= 4.0~) but 3.0.1-1 is to be installed
      Depends: node-tar (>= 4.4~) but it is not going to be installed
      Depends: node-which (>= 1.3~) but 1.2.11-1 is to be installed
node-libnpx : Depends: node-rimraf (>= 2.6.1) but 2.5.4-2 is to be installed
              Depends: node-which (>= 1.2.14) but 1.2.11-1 is to be installed
              Depends: node-yargs (>= 8.0.2) but it is not going to be installed
node-config-chain : Depends: node-ini (>= 1.3.4) but 1.1.0-1 is to be installed
node-cacache : Depends: node-glob (>= 7.1.2) but 7.1.1-1 is to be installed
               Depends: node-lru-cache (>= 4.1.1) but 4.0.2-1 is to be installed
               Depends: node-mkdirp (>= 0.5.1) but 0.5.0-1 is to be installed
               Depends: node-rimraf (>= 2.6.1) but 2.5.4-2 is to be installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)      node-boxen [Not Installed]                         
2)      node-cacache [Not Installed]                       
3)      node-config-chain [Not Installed]                  
4)      node-copy-concurrently [Not Installed]             
5)      node-got [Not Installed]                           
6)      node-latest-version [Not Installed]                
7)      node-libnpx [Not Installed]                        
8)      node-move-concurrently [Not Installed]             
9)      node-npm-package-arg [Not Installed]               
10)     node-package-json [Not Installed]                  
11)     node-timed-out [Not Installed]                     
12)     npm [Not Installed]                                

如果我選擇 y

Accept this solution? [Y/n/q/?] y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 30 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.

沒有npm安裝。

npm
bash: npm: command not found

我如何npm在 debian 伸展上安裝?

對於較新的節點和 npm 版本,請閱讀並遵循 NodeSource 安裝說明:

要安裝目前版本 (14.x),請執行

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

(在 Debian Buster 上它安裝了節點 v14.5.0 / npm 6.14.5)


如果您想從 Debian backports 儲存庫安裝較舊的 npm(和 nodejs)版本,您需要將 backports 儲存庫添加到您的包源中。

添加此行以/etc/apt/sources.list啟用 main、contrib 和 non-free repos 的二進制包(後兩者是可選的):

deb http://deb.debian.org/debian stretch-backports main contrib non-free

然後執行

sudo apt update
sudo apt -t stretch-backports install npm

您可以nodejs使用 backports 儲存庫升級到 v8.11.1

sudo apt -t stretch-backports install nodejs

引用自:https://unix.stackexchange.com/questions/598016