4

我尝试使用以下命令将 pg 模块安装到 Node.js:npm install pg

起初我必须安装 Python。然后是 PostgreSQL 8.x,然后是 Microsoft Visual C++。但我还是做不到。编译时出现错误:

npm http GET https://registry.npmjs.org/pg
npm http 304 https://registry.npmjs.org/pg
npm http GET https://registry.npmjs.org/generic-pool/1.0.9
npm http 304 https://registry.npmjs.org/generic-pool/1.0.9

> pg@0.7.2 install C:\Users\Adam\node_modules\pg
> node-gyp rebuild || (exit 0)

C:\Users\Adam\node_modules\pg>node "C:\Program Files\nodejs\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
  binding.cc
c:\users\adam\.node-gyp\0.8.1\src\node_object_wrap.h(57): warning C4251: 'node:
:ObjectWrap::handle_' : class 'v8::Persistent<T>' needs to have dll-interface t
o be used by clients of class 'node::ObjectWrap' [C:\Users\Adam\node_modules\pg
\build\binding.vcxproj]
          with
          [
              T=v8::Object
          ]
..\src\binding.cc(83): error C2061: syntax error : identifier 'EV_P_' [C:\Users
\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(237): error C2146: syntax error : missing ';' before identifi
er 'read_watcher_' [C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(237): error C4430: missing type specifier - int assumed. Note
: C++ does not support default-int [C:\Users\Adam\node_modules\pg\build\binding
.vcxproj]
..\src\binding.cc(237): error C4430: missing type specifier - int assumed. Note
: C++ does not support default-int [C:\Users\Adam\node_modules\pg\build\binding
.vcxproj]
..\src\binding.cc(238): error C2146: syntax error : missing ';' before identifi
er 'write_watcher_' [C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(238): error C4430: missing type specifier - int assumed. Note
: C++ does not support default-int [C:\Users\Adam\node_modules\pg\build\binding
.vcxproj]
..\src\binding.cc(238): error C4430: missing type specifier - int assumed. Note
: C++ does not support default-int [C:\Users\Adam\node_modules\pg\build\binding
.vcxproj]
..\src\binding.cc(86): error C2065: 'w' : undeclared identifier [C:\Users\Adam\
node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(86): error C2227: left of '->data' must point to class/struct
/union/generic type [C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
          type is ''unknown-type''
..\src\binding.cc(87): error C2065: 'revents' : undeclared identifier [C:\Users
\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(117): warning C4800: 'int' : forcing value to bool 'true' or
'false' (performance warning) [C:\Users\Adam\node_modules\pg\build\binding.vcxp
roj]
..\src\binding.cc(247): error C2065: 'read_watcher_' : undeclared identifier [C
:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(247): error C3861: 'ev_init': identifier not found [C:\Users\
Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(248): error C2065: 'read_watcher_' : undeclared identifier [C
:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(248): error C2228: left of '.data' must have class/struct/uni
on [C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
          type is ''unknown-type''
..\src\binding.cc(249): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(249): error C3861: 'ev_init': identifier not found [C:\Users\
Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(250): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(250): error C2228: left of '.data' must have class/struct/uni
on [C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
          type is ''unknown-type''
..\src\binding.cc(312): error C2065: 'EV_DEFAULT_' : undeclared identifier [C:\
Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(312): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(312): error C3861: 'ev_io_start': identifier not found [C:\Us
ers\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(358): error C2065: 'read_watcher_' : undeclared identifier [C
:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(358): error C2065: 'EV_READ' : undeclared identifier [C:\User
s\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(358): error C3861: 'ev_io_set': identifier not found [C:\User
s\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(359): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(359): error C2065: 'EV_WRITE' : undeclared identifier [C:\Use
rs\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(359): error C3861: 'ev_io_set': identifier not found [C:\User
s\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(384): error C2065: 'EV_ERROR' : undeclared identifier [C:\Use
rs\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(395): error C2065: 'EV_READ' : undeclared identifier [C:\User
s\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(434): error C2065: 'EV_WRITE' : undeclared identifier [C:\Use
rs\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(623): error C2065: 'EV_DEFAULT_' : undeclared identifier [C:\
Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(623): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(623): error C3861: 'ev_io_stop': identifier not found [C:\Use
rs\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(629): error C2065: 'EV_DEFAULT_' : undeclared identifier [C:\
Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(629): error C2065: 'write_watcher_' : undeclared identifier [
C:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(629): error C3861: 'ev_io_start': identifier not found [C:\Us
ers\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(635): error C2065: 'EV_DEFAULT_' : undeclared identifier [C:\
Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(635): error C2065: 'read_watcher_' : undeclared identifier [C
:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(635): error C3861: 'ev_io_stop': identifier not found [C:\Use
rs\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(641): error C2065: 'EV_DEFAULT_' : undeclared identifier [C:\
Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(641): error C2065: 'read_watcher_' : undeclared identifier [C
:\Users\Adam\node_modules\pg\build\binding.vcxproj]
..\src\binding.cc(641): error C3861: 'ev_io_start': identifier not found [C:\Us
ers\Adam\node_modules\pg\build\binding.vcxproj]
gyp ERR! rebuild error Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msb
uild.exe` failed with exit code: 1
gyp ERR! rebuild error     at ChildProcess.onExit (C:\Program Files\nodejs\node_
modules\npm\node_modules\node-gyp\lib\build.js:214:23)
gyp ERR! rebuild error     at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! rebuild error     at Process._handle.onexit (child_process.js:674:10)
gyp ERR! not ok
pg@0.7.2 node_modules\pg
└── generic-pool@1.0.9 

有任何想法吗?如果没有这个模块,我无法通过 Node.js 连接到我的 PostgreSQL 数据库。

4

0 回答 0