2012-08-27 130 views
1

我嘗試安裝iconv模塊,但它總是停留在:Node.js的:無法安裝的iconv模塊

^[email protected]: server$ npm install iconv 
npm http GET https://registry.npmjs.org/iconv 
npm http 304 https://registry.npmjs.org/iconv 

> [email protected] install /Users/yippeeyippee/Desktop/nodejs/tinman/server/node_modules/iconv 
> node-gyp rebuild 

gyp http GET http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz 
gyp http 200 http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz 

我不知道發生了什麼,成功還是失敗,我怎麼能解決這個問題?

更新:

等待很長一段時間:,我得到了這樣的失敗信息後:

xcode-select: Error: No Xcode is selected. Use xcode-select -switch /Applications/Xcode.app to select /Applications/Xcode.app, or see the xcode-select manpage (man xcode-select) for further information. 

Traceback (most recent call last): 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/gyp", line 18, in <module> 
    sys.exit(gyp.main(sys.argv[1:])) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/__init__.py", line 480, in main 
    generator.GenerateOutput(flat_list, targets, data, params) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/generator/make.py", line 2082, in GenerateOutput 
    part_of_all=qualified_target in needed_targets) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/generator/make.py", line 764, in Write 
    self.Pchify)) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/generator/make.py", line 1137, in WriteSources 
    cflags = self.xcode_settings.GetCflags(configname) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/xcode_emulation.py", line 259, in GetCflags 
    sdk_root = self._SdkPath() 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/xcode_emulation.py", line 248, in _SdkPath 
    return os.path.join(self._GetSdkBaseDir(), '%s.sdk' % sdk_root) 
    File "/Users/yippeeyippee/.node-gyp/0.8.7/tools/gyp/pylib/gyp/xcode_emulation.py", line 234, in _GetSdkBaseDir 
    raise Exception('Error %d running xcode-select' % job.returncode) 
Exception: Error 1 running xcode-select 
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1 
gyp ERR! stack  at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:346:16) 
gyp ERR! stack  at ChildProcess.EventEmitter.emit (events.js:91:17) 
gyp ERR! stack  at Process._handle.onexit (child_process.js:674:10) 
gyp ERR! System Darwin 11.4.0 
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild" 
gyp ERR! cwd /Users/yippeeyippee/Desktop/nodejs/tinman/server/node_modules/iconv 
gyp ERR! node -v v0.8.7 
gyp ERR! node-gyp -v v0.6.8 
gyp ERR! not ok 
npm ERR! [email protected] install: `node-gyp rebuild` 
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script. 
npm ERR! This is most likely a problem with the iconv package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node-gyp rebuild 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls iconv 
npm ERR! There is likely additional logging output above. 

npm ERR! System Darwin 11.4.0 
npm ERR! command "node" "/usr/local/bin/npm" "install" "iconv" 
npm ERR! cwd /Users/yippeeyippee/Desktop/nodejs/tinman/server 
npm ERR! node -v v0.8.7 
npm ERR! npm -v 1.1.49 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /Users/yippeeyippee/Desktop/nodejs/tinman/server/npm-debug.log 
npm ERR! not ok code 0 
+0

您是否正確安裝節點GYP和它的依賴? https://github.com/TooTallNate/node-gyp – JohnnyHK

+0

@JohnnyHK:我已經安裝了v0.6.8 – hh54188

回答

14

命令行工具(不使用Xcode的)方法

  1. 下載並安裝Mac OS X開發Command Line Tools
  2. 運行sudo xcode-select --switch /usr/bin。有關詳細信息,
  3. homebrew issue 10245重新嘗試npm install iconv

Xcode的版本(由我未經測試)

  1. 下載並安裝全Xcode
  2. 試試你的npm install iconv一次。如果有效,你就完成了。
  3. 如果你得到同樣的錯誤,請嘗試sudo xcode-select --switch /Applications/Xcode.app然後重試npm install iconv
+2

我有「錯誤:'gyp'失敗,退出代碼:1」並且運行「sudo xcode-select -switch/usr/bin」完成了這項工作! Thanx! – vinyll

+0

爲我工作。謝謝! –

+0

謝謝!此解決方案似乎修復了npm pg軟件包的node-gyp錯誤(postgres) – Kreegr

0

在這一步的節點GYP安裝程序下載Node.js的源代碼。這可能需要很長時間,並取決於連接速度。例如:我在等待大約20-25分鐘的服務器上,在中國的連接速度很慢。

+0

也許這不是問題,我已經更新了失敗的信息; – hh54188

+0

您使用的是Mac OS嗎?嘗試在這裏看到相同的問題https://github.com/mxcl/homebrew/issues/10245。執行「sudo xcode-select -switch /Applications/Xcode.app」可能對您有所幫助。但是我沒有Mac OS來檢查這個。 –