2014-03-04 167 views
1

我遇到問題在OSX和Ubuntu上安裝odbc軟件包。npm install odbc在OSX和Ubuntu上失敗

我在這兩臺機器上安裝了unixODBC。

這裏是發行 「故宮安裝ODBC」 的輸出:

npm http GET https://registry.npmjs.org/odbc 
npm http 304 https://registry.npmjs.org/odbc 

> [email protected] preinstall /home/notes/as400/node_modules/odbc 
> node-gyp configure build 

Traceback (most recent call last): 
    File "/usr/share/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module> 
    sys.exit(gyp.script_main()) 
AttributeError: 'module' object has no attribute 'script_main' 
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1 
gyp ERR! stack  at ChildProcess.onCpExit (/usr/share/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16) 
gyp ERR! stack  at ChildProcess.EventEmitter.emit (events.js:98:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:797:12) 
gyp ERR! System Linux 3.11.0-12-generic 
gyp ERR! command "node" "/usr/share/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" 
gyp ERR! cwd /home/notes/as400/node_modules/odbc 
gyp ERR! node -v v0.10.26 
gyp ERR! node-gyp -v v0.12.2 
gyp ERR! not ok 
npm ERR! [email protected] preinstall: `node-gyp configure build` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script. 
npm ERR! This is most likely a problem with the odbc package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node-gyp configure build 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls odbc 
npm ERR! There is likely additional logging output above. 

npm ERR! System Linux 3.11.0-12-generic 
npm ERR! command "/usr/share/node/bin/node" "/usr/share/node/bin/npm" "install" "odbc" 
npm ERR! cwd /home/notes/as400 
npm ERR! node -v v0.10.26 
npm ERR! npm -v 1.4.3 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /home/notes/as400/npm-debug.log 
npm ERR! not ok code 0 

編輯2014年3月5日 我的MacPorts使用沒有任何問題,安裝了unixODBC我的Mac上。現在,當我嘗試「故宮安裝ODBC --save」,我得到sql.h以下錯誤丟失:

npm http GET https://registry.npmjs.org/odbc 
npm http 304 https://registry.npmjs.org/odbc 

> [email protected] preinstall /Users/patrick/IdeaProjects/XTL/vouchers-paid/node_modules/odbc 
> node-gyp configure build 

    CXX(target) Release/obj.target/odbc_bindings/src/odbc.o 
In file included from ../src/odbc.cpp:25: 
../src/odbc.h:29:10: fatal error: 'sql.h' file not found 
#include <sql.h> 
     ^
1 error generated. 
make: *** [Release/obj.target/odbc_bindings/src/odbc.o] Error 1 
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2 
gyp ERR! stack  at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23) 
gyp ERR! stack  at ChildProcess.EventEmitter.emit (events.js:98:17) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (child_process.js:797:12) 
gyp ERR! System Darwin 13.0.0 
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build" 
gyp ERR! cwd /Users/patrick/IdeaProjects/XTL/vouchers-paid/node_modules/odbc 
gyp ERR! node -v v0.10.26 
gyp ERR! node-gyp -v v0.10.10 
gyp ERR! not ok 
npm ERR! weird error 1 
npm ERR! not ok code 0 

回答

2

上npmjs.org指出有需要安裝其他二進制文件:

> on Ubuntu/Debian sudo apt-get install unixodbc unixodbc-dev 
> on OSX using macports.org sudo port unixODBC 

更多信息:https://www.npmjs.org/package/odbc

+0

很肯定我在Ubuntu的所有DEPS。我記得安裝unixodbc-dev。至於OSX,我從unixodbc.org下載了unixodbc,並從源代碼構建。用odbc軟件包不能正常工作嗎? –

+0

我已經配置了unixodbc和unixodbc-dev都安裝在我的Ubuntu服務器上。 –

+0

使用Macports成功安裝unixODBC後,我得到一個關於sql.h缺失的新錯誤。 –

2
sudo port unixODBC 

也是錯誤的。

sudo port install unixodbc 

是對的。

端口將lib和頭文件安裝在其他目錄/ opt/local/include和/ opt/local/lib中。要使用它們,你必須告訴npm或環境。 但不知道如何。願有人更有經驗。

或者你用自制:

brew install unixodbc 

,將工作。

+0

$ C_INCLUDE_PATH = /選擇/本地/包括中:/ opt/local/lib目錄 $ CPLUS_INCLUDE_PATH = /選擇/本地/包括中:/ opt/local/lib目錄 $ NPM安裝ODBC $出口C_INCLUDE_PATH $出口CPLUS_INCLUDE_PATH – TOBlender

0

使用 sudo的港口安裝了unixODBC

$ C_INCLUDE_PATH=/Where_You_Installed/ibm/dsdriver/include 
$ CPLUS_INCLUDE_PATH=/Where_You_Installed/ibm/dsdriver/include 
$ export C_INCLUDE_PATH 
$ export CPLUS_INCLUDE_PATH 

然後運行

npm install ibm_db 
5

這裏安裝後對我工作(OSX 10.10.2)

  1. 通過安裝unixODBC MacPorts 沒有w ork。端口本身 安裝並自動更新包含路徑,編譯器 找到sql.h。但是,然後鏈接器失敗。

  2. 安裝unixodbc通過自制軟件工程。包含路徑不是 已更新,但可以修復,如其他答案所示。

對於安裝odbc包,你可以使用下面的shell腳本:

#!/usr/bin/env bash 

SRC_ODBC=/usr/local/Cellar/unixodbc/2.3.2_1/include 
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$SRC_ODBC 
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$SRC_ODBC 
npm install odbc 
+0

這個工作對我也是!謝謝! – sankargorthi