2011-11-26 60 views
0

我刚开始进入node.js,希望将node.js与我在MAMP上运行的现有PHP/MySQL堆栈一起使用。安装db-mysql

问题:我现有的数据已经存在于以MAMP开头的MySQL数据库中,我想从node.js访问它们。我决定使用db-mysql驱动程序等安装它,我指定我MYSQL_CONFIG环境通过在终端

  1. export MYSQL_CONFIG=/Applications/MAMP/Library/bin/mysql_config
  2. NPM安装DB-mysql的

然后是错误消息键入:

> [email protected] install /Users/x/mywebsite/node_modules/db-mysql 
> node-waf configure build 

Checking for program g++ or c++   : /usr/bin/g++ 
Checking for program cpp     : /usr/bin/cpp 
Checking for program ar     : /usr/bin/ar 
Checking for program ranlib    : /usr/bin/ranlib 
Checking for g++       : ok 
Checking for node path     : not found 
Checking for node prefix     : ok /usr/local 
Checking for program mysql_config  : /Applications/MAMP/Library/bin/mysql_config 
Checking for library mysqlclient_r  : Missing libmysqlclient_r 
'configure' finished successfully (0.571s) 
Waf: Entering directory `/Users/x/mywebsite/node_modules/db-mysql/build' 
[ 1/12] cxx: lib/node-db/binding.cc -> build/Release/lib/node-db/binding_1.o 
[ 2/12] cxx: lib/node-db/connection.cc -> build/Release/lib/node-db/connection_1.o 
[ 3/12] cxx: lib/node-db/events.cc -> build/Release/lib/node-db/events_1.o 
[ 4/12] cxx: lib/node-db/exception.cc -> build/Release/lib/node-db/exception_1.o 
[ 5/12] cxx: lib/node-db/query.cc -> build/Release/lib/node-db/query_1.o 
[ 6/12] cxx: lib/node-db/result.cc -> build/Release/lib/node-db/result_1.o 
[ 7/12] cxx: src/connection.cc -> build/Release/src/connection_1.o 
In file included from ../src/connection.cc:2: 
../src/./connection.h:5:19: error: mysql.h: No such file or directory 
In file included from ../src/./connection.h:8, 
       from ../src/connection.cc:2: 
../src/././result.h:16: error: expected ‘,’ or ‘...’ before ‘&’ token 
../src/././result.h:16: error: ISO C++ forbids declaration of ‘MYSQL_FIELD’ with no type 
../src/././result.h:28: error: expected `)' before ‘*’ token 
../src/././result.h:54: error: ISO C++ forbids declaration of ‘MYSQL’ with no type 
../src/././result.h:54: error: expected ‘;’ before ‘*’ token 
../src/././result.h:55: error: ISO C++ forbids declaration of ‘MYSQL_RES’ with no type 
../src/././result.h:55: error: expected ‘;’ before ‘*’ token 
In file included from ../src/connection.cc:2: 
../src/./connection.h:43: error: ISO C++ forbids declaration of ‘MYSQL’ with no type 
../src/./connection.h:43: error: expected ‘;’ before ‘*’ token 
../src/connection.cc: In constructor ‘node_db_mysql::Connection::Connection()’: 
../src/connection.cc:11: error: class ‘node_db_mysql::Connection’ does not have any field named ‘connection’ 
../src/connection.cc: In member function ‘virtual bool node_db_mysql::Connection::isAlive(bool)’: 
../src/connection.cc:57: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:57: error: ‘mysql_ping’ was not declared in this scope 
../src/connection.cc: In member function ‘virtual void node_db_mysql::Connection::open()’: 
../src/connection.cc:65: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:65: error: ‘mysql_init’ was not declared in this scope 
../src/connection.cc:66: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:71: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:71: error: ‘MYSQL_SET_CHARSET_NAME’ was not declared in this scope 
../src/connection.cc:71: error: ‘mysql_options’ was not declared in this scope 
../src/connection.cc:75: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:75: error: ‘MYSQL_OPT_COMPRESS’ was not declared in this scope 
../src/connection.cc:75: error: ‘mysql_options’ was not declared in this scope 
../src/connection.cc:79: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:79: error: ‘MYSQL_INIT_COMMAND’ was not declared in this scope 
../src/connection.cc:79: error: ‘mysql_options’ was not declared in this scope 
../src/connection.cc:83: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
[ 8/12] cxx: src/mysql.cc -> build/Release/src/mysql_1.o 
../src/connection.cc:83: error: ‘MYSQL_OPT_READ_TIMEOUT’ was not declared in this scope 
../src/connection.cc:83: error: ‘mysql_options’ was not declared in this scope 
../src/connection.cc:90: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:90: error: ‘MYSQL_OPT_SSL_VERIFY_SERVER_CERT’ was not declared in this scope 
../src/connection.cc:90: error: ‘mysql_options’ was not declared in this scope 
../src/connection.cc:93: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:93: error: ‘MYSQL_OPT_CONNECT_TIMEOUT’ was not declared in this scope 
../src/connection.cc:97: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:97: error: ‘MYSQL_OPT_WRITE_TIMEOUT’ was not declared in this scope 
../src/connection.cc:101: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:108: error: ‘mysql_real_connect’ was not declared in this scope 
../src/connection.cc:116: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:116: error: ‘mysql_error’ was not declared in this scope 
../src/connection.cc: In member function ‘virtual void node_db_mysql::Connection::close()’: 
../src/connection.cc:122: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:122: error: ‘mysql_close’ was not declared in this scope 
../src/connection.cc: In member function ‘virtual std::string node_db_mysql::Connection::escape(const std::string&) const’: 
../src/connection.cc:133: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:133: error: ‘mysql_real_escape_string’ was not declared in this scope 
../src/connection.cc: In member function ‘virtual std::string node_db_mysql::Connection::version() const’: 
../src/connection.cc:141: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:141: error: ‘mysql_get_server_info’ was not declared in this scope 
../src/connection.cc: In member function ‘virtual node_db::Result* node_db_mysql::Connection::query(const std::string&) const’: 
../src/connection.cc:150: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:150: error: ‘mysql_real_query’ was not declared in this scope 
../src/connection.cc:151: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’ 
../src/connection.cc:151: error: ‘mysql_error’ was not declared in this scope 
../src/connection.cc:154: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’ 
In file included from ../src/./mysql.h:7, 
       from ../src/mysql.cc:2: 
../src/././connection.h:5:19: error: mysql.h: No such file or directory 
In file included from ../src/././connection.h:8, 
       from ../src/./mysql.h:7, 
       from ../src/mysql.cc:2: 
../src/./././result.h:16: error: expected ‘,’ or ‘...’ before ‘&’ token 
../src/./././result.h:16: error: ISO C++ forbids declaration of ‘MYSQL_FIELD’ with no type 
../src/./././result.h:28: error: expected `)' before ‘*’ token 
../src/./././result.h:54: error: ISO C++ forbids declaration of ‘MYSQL’ with no type 
../src/./././result.h:54: error: expected ‘;’ before ‘*’ token 
../src/./././result.h:55: error: ISO C++ forbids declaration of ‘MYSQL_RES’ with no type 
../src/./././result.h:55: error: expected ‘;’ before ‘*’ token 
In file included from ../src/./mysql.h:7, 
       from ../src/mysql.cc:2: 
../src/././connection.h:43: error: ISO C++ forbids declaration of ‘MYSQL’ with no type 
../src/././connection.h:43: error: expected ‘;’ before ‘*’ token 
Waf: Leaving directory `/Users/x/mywebsite/node_modules/db-mysql/build' 
Build failed: 
-> task failed (err #1): 
    {task: cxx connection.cc -> connection_1.o} 
-> task failed (err #1): 
    {task: cxx mysql.cc -> mysql_1.o} 
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf configure build` 
npm ERR! error installing [email protected] `sh "-c" "node-waf configure build"` failed with 1 
npm ERR! error installing [email protected]  at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20) 
npm ERR! error installing [email protected]  at ChildProcess.emit (events.js:70:17) 
npm ERR! error installing [email protected]  at maybeExit (child_process.js:359:16) 
npm ERR! error installing [email protected]  at Process.onexit (child_process.js:395:5) 

> [email protected] preuninstall /Users/x/mywebsite/node_modules/db-mysql 
> rm -rf build/* 

npm ERR! [email protected] install: `node-waf configure build` 
npm ERR! `sh "-c" "node-waf configure build"` failed with 1 
npm ERR! 
npm ERR! Failed at the [email protected] install script. 
npm ERR! This is most likely a problem with the db-mysql package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node-waf configure build 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls db-mysql 
npm ERR! There is likely additional logging output above. 
npm ERR! 
npm ERR! System Darwin 11.2.0 
npm ERR! command "node" "/usr/local/bin/npm" "install" "db-mysql" 
npm ERR! cwd /Users/x/mywebsite 
npm ERR! node -v v0.6.2 
npm ERR! npm -v 1.0.106 
npm ERR! code ELIFECYCLE 
npm ERR! 
npm ERR! Additional logging details can be found in: 
npm ERR!  /Users/x/mywebsite/npm-debug.log 
npm not ok 

我哪里出错了?或者有更好的方法来设置db-mysql

+0

node-mysql工作,但不是db-mysql ... – Nyxynyx

回答

1

node-mysql一起工作很好