1. 程式人生 > >npm 安裝出現 UNMET DEPENDENCY 的解決方案

npm 安裝出現 UNMET DEPENDENCY 的解決方案

npm install express -g
...
npm list -g
D:\Users\Ls\AppData\Roaming\npm
└─┬ express@3.4.8
  ├── buffer-crc32@0.2.1
  ├─┬ commander@1.3.2
  │ └── keypress@0.1.0
  ├─┬ connect@2.12.0
  │ ├── UNMET DEPENDENCY batch 0.5.0
  │ ├── UNMET DEPENDENCY bytes 0.2.1
  │ ├── UNMET DEPENDENCY multiparty 2.2.0
  │ ├── UNMET DEPENDENCY negotiator 0
.3.0 │ ├── UNMET DEPENDENCY pause 0.0.1 │ ├── UNMET DEPENDENCY qs 0.6.6 │ ├── UNMET DEPENDENCY raw-body 1.1.2 │ └── UNMET DEPENDENCY uid2 0.0.3 ├── cookie@0.1.0 ├── cookie-signature@1.0.1 ├── debug@0.7.4 ├── fresh@0.2.0 ├── merge-descriptors@0.0.1 ├── methods@0.1.0 ├── mkdirp@0.3.5 ├── range-parser@0
.0.4 └─┬ send@0.1.4 └── mime@1.2.11 npm ERR! missing: batch@0.5.0, required by connect@2.12.0 npm ERR! missing: bytes@0.2.1, required by connect@2.12.0 npm ERR! missing: pause@0.0.1, required by connect@2.12.0 ... npm ERR! not ok code 0

今天安裝一些模組的時候發現 npm install 到了一個點之後就卡住了一樣等了半天一直不動,接著中斷看了下出現安裝出現了 UNMET DEPENDENCY 的 模組,這個時候如果重新 install 一便的話,又會重頭開始,如果又碰到卡殼就很煩。所以用list 命令檢視之後決定用另外一種解決方案來解決這個問題,即跑到缺失模組的目錄下去安裝:

D:\Users\Ls\AppData\Roaming\npm\node_modules\express\node_modules\connect>npm install uid2
...
D:\Users\Ls\AppData\Roaming\npm\node_modules\express\node_modules\connect>npm list -g
D:\Users\Ls\AppData\Roaming\npm
└─┬ express@3.4.8
  ├── buffer-crc32@0.2.1
  ├─┬ commander@1.3.2
  │ └── keypress@0.1.0
  ├─┬ connect@2.12.0
  │ ├── UNMET DEPENDENCY batch 0.5.0
  │ ├── UNMET DEPENDENCY bytes 0.2.1
  │ ├── UNMET DEPENDENCY multiparty 2.2.0
  │ ├── UNMET DEPENDENCY negotiator 0.3.0
  │ ├── UNMET DEPENDENCY pause 0.0.1
  │ ├── UNMET DEPENDENCY qs 0.6.6
  │ ├── UNMET DEPENDENCY raw-body 1.1.2
  │ └── uid2@0.0.3
  ├── cookie@0.1.0
  ├── cookie-signature@1.0.1
  ├── debug@0.7.4
  ├── fresh@0.2.0
  ├── merge-descriptors@0.0.1
  ├── methods@0.1.0
  ├── mkdirp@0.3.5
  ├── range-parser@0.0.4
  └─┬ send@0.1.4
    └── mime@1.2.11

npm ERR! missing: batch@0.5.0, required by connect@2.12.0
npm ERR! missing: qs@0.6.6, required by connect@2.12.0
npm ERR! missing: bytes@0.2.1, required by connect@2.12.0
npm ERR! missing: pause@0.0.1, required by connect@2.12.0
npm ERR! missing: raw-body@1.1.2, required by connect@2.12.0
npm ERR! missing: negotiator@0.3.0, required by connect@2.12.0
npm ERR! missing: multiparty@2.2.0, required by connect@2.12.0
npm ERR! not ok code 0

看 log 發現已經解決了一個 uid2 的依賴,剩下的依次類推,在該 connect 模組下手動 install 就可以解決這些 UNMET DEPENDENCY 的問題了。(用 sublime 拼一下很快的)