2014-03-25 522 views
4

,而我想我得到下面的錯誤在我的Ubuntu機器錯誤:無法找到模塊「mkdirp」

node.js:201 
     throw e; // process.nextTick error, or 'error' event on first tick 
      ^
Error: Cannot find module 'mkdirp' 
    at Function._resolveFilename (module.js:332:11) 
    at Function._load (module.js:279:25) 
    at Module.require (module.js:354:17) 
    at require (module.js:370:17) 
    at Object.<anonymous> (/home//dev/ation/siya/common.js:7:19) 
    at Module._compile (module.js:441:26) 
    at Object..js (module.js:459:10) 
    at Module.load (module.js:348:31) 
    at Function._load (module.js:308:12) 
    at Module.require (module.js:354:17) 

所以我嘗試npm install mkdirp

npm http GET https://registry.npmjs.org/mkdirp 

npm ERR! Error: failed to fetch from registry: mkdirp 
npm ERR!  at /home/local/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12 
npm ERR!  at cb (/home/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:31:9) 
npm ERR!  at Request._callback (/home/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:136:18) 
npm ERR!  at Request.callback (/home//local/lib/node_modules/npm/node_modules/request/main.js:119:22) 
npm ERR!  at Request.<anonymous> (/home/local/lib/node_modules/npm/node_modules/request/main.js:212:58) 
npm ERR!  at Request.emit (events.js:88:20) 
npm ERR!  at ClientRequest.<anonymous> (/home/local/lib/node_modules/npm/node_modules/request/main.js:412:12) 
npm ERR!  at ClientRequest.emit (events.js:67:17) 
npm ERR!  at HTTPParser.onIncoming (http.js:1261:11) 
npm ERR!  at HTTPParser.onHeadersComplete (http.js:102:31) 
npm ERR! You may report this log at: 
npm ERR!  <http://github.com/isaacs/npm/issues> 
npm ERR! or email it to: 
npm ERR!  <[email protected]> 
npm ERR! 
npm ERR! System Linux 3.2.0-23-generic 
npm ERR! command "node" "/home/local/bin/npm" "install" "mkdirp" 
npm ERR! cwd /home/dev/tst_tion/servrs/sc 
npm ERR! node -v v0.6.12 
npm ERR! npm -v 1.1.4 
npm ERR! message failed to fetch from registry: mkdirp 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/npm-debug.log 
npm not ok 

我怎樣才能解決這個運行的NodeJS文件問題

NPM文件的debug.log

info it worked if it ends with ok 
verbose cli [ 'node', '/home/ushusadmin/local/bin/npm', 'install', 'mkdirp' ] 
info using [email protected] 
info using [email protected] 
verbose config file /home/ushusadmin/.npmrc 
verbose config file /home/ushusadmin/local/etc/npmrc 
verbose config file /home/ushusadmin/local/lib/node_modules/npm/npmrc 
verbose caching /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/node_modules/node-schedule/package.json 
verbose caching /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/node_modules/nodemailer/package.json 
verbose caching /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/node_modules/mustache/package.json 
verbose caching /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/node_modules/qs/package.json 
verbose caching /home/ushusadmin/dev/test_automation/servers/scriptAgentServer/node_modules/mongodb/package.json 
verbose cache add [ 'mkdirp', null ] 
silly cache add: name, spec, args [ undefined, 'mkdirp', [ 'mkdirp', null ] ] 
verbose parsed url { pathname: 'mkdirp', path: 'mkdirp', href: 'mkdirp' } 
verbose addNamed [ 'mkdirp', '' ] 
verbose addNamed [ null, '' ] 
silly name, range, hasData [ 'mkdirp', '', false ] 
verbose raw, before any munging mkdirp 
verbose url resolving [ 'https://registry.npmjs.org/', './mkdirp' ] 
verbose url resolved https://registry.npmjs.org/mkdirp 
http GET https://registry.npmjs.org/mkdirp 
ERR! Error: failed to fetch from registry: mkdirp 
ERR!  at /home/ushusadmin/local/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12 
ERR!  at cb (/home/ushusadmin/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:31:9) 
ERR!  at Request._callback (/home/ushusadmin/local/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:136:18) 
ERR!  at Request.callback (/home/ushusadmin/local/lib/node_modules/npm/node_modules/request/main.js:119:22) 
ERR!  at Request.<anonymous> (/home/ushusadmin/local/lib/node_modules/npm/node_modules/request/main.js:212:58) 
ERR!  at Request.emit (events.js:88:20) 
ERR!  at ClientRequest.<anonymous> (/home/ushusadmin/local/lib/node_modules/npm/node_modules/request/main.js:412:12) 
ERR!  at ClientRequest.emit (events.js:67:17) 
ERR!  at HTTPParser.onIncoming (http.js:1261:11) 
ERR!  at HTTPParser.onHeadersComplete (http.js:102:31) 
ERR! You may report this log at: 
ERR!  <http://github.com/isaacs/npm/issues> 
ERR! or email it to: 
ERR!  <[email protected]> 
ERR! 
ERR! System Linux 3.2.0-23-generic 
ERR! command "node" "/home/ushusadmin/local/bin/npm" "install" "mkdirp" 
ERR! cwd /home/ushusadmin/dev/test_automation/servers/scriptAgentServer 
ERR! node -v v0.6.12 
ERR! npm -v 1.1.4 
ERR! message failed to fetch from registry: mkdirp 
verbose exit [ 1, true ] 

實際上發生了什麼,同時試圖安裝使用comamnd sikuli刪除以下items..how我可以恢復這個項目

$ sudo的性向安裝sikuli-IDE

Removing libc-ares-dev ... 
Removing libc-ares2 ... 
Removing libev-dev ... 
Removing libev4 ... 
Removing libv8-dev ... 
Removing libv8-3.7.12.22 ... 
Removing node-abbrev ... 
Removing node-tar ... 
Removing node-block-stream ... 
Removing node-fstream ... 
Removing node-graceful-fs ... 
Removing node-inherits ... 
Removing node-ini ... 
Removing node-minimatch ... 
Removing node-lru-cache ... 
Removing node-mkdirp ... 
Removing node-node-uuid ... 
Removing node-nopt ... 
Removing node-request ... 
Removing node-rimraf ... 
Removing node-semver ... 
Removing node-which ... 
+0

你拼mkdirp錯了嗎? '錯誤:無法從註冊表中獲取:kdirp' –

+0

你可以顯示'npm-debug.log'中的內容嗎? –

+0

對不起,實際上它是mkdirp – Sush

回答

7

使用的手工工藝安裝mkdirp:

使用的去除包裝的廣義化:

  • 轉到https://registry.npmjs.org/ {模塊} /最新
  • 複製網址值的「tarball」:鍵
  • 下載壓縮包
  • 在node_modules pa下展開它TH

作爲替代,使用NPM安裝名@版本語法:

npm install [email protected] 

或者故宮安裝git的語法:

npm install git://github.com/substack/node-mkdirp.git 

參考

+0

你能解釋爲什麼這是必要的嗎?當試圖在一個項目上啓動'http-server'時遇到了這個錯誤,當'http-server'在另一個項目上運行正常時,在'node_modules'文件夾中沒有這個神祕的'mkdirp'。 – ray

+0

@ray它看起來像模塊的'nodeVersion'參數與機器上安裝的節點版本不匹配,所以它無法在NPM註冊表中找到兼容版本的'mkdirp'來自動安裝。 [類似問題](http://stackoverflow.com/questions/14949118/1113772)是指設置NODE_PATH環境變量。 [semver](https://www.npmjs.org/doc/misc/semver.html)會是一個更好的方法,並且還有一個[修復](https://github.com/npm/npm/commit/) 9d73de7f8a0285bfb9f4fc8f4ca1300c387fdd05)在npm-2.0中刪除多餘的'mkdirp'引用。 –

1

以我爲例,我試圖從一個目錄,我的用戶沒有足夠的權限運行npm install。看看這些,看看是否可能是這個問題。

0

試用紗包經理,通過使用yarn命令。它爲我解決了這種問題