无法安装node-postgres node.js模块

时间:2023-02-10 10:39:32

Please, observe:

请观察:

c:\Work\if\server>npm install pg
npm WARN package.json passport@0.1.15 No README data
npm WARN package.json passport-http@0.2.1 No README data
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/2.0.3
npm http GET https://registry.npmjs.org/buffer-writer/1.0.0
npm http 304 https://registry.npmjs.org/generic-pool/2.0.3
npm http 304 https://registry.npmjs.org/buffer-writer/1.0.0
npm http GET https://registry.npmjs.org/cloned/0.0.1
npm http GET https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/cloned/0.0.1
npm http 304 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/rmdir
npm http 304 https://registry.npmjs.org/rmdir

> pg@2.6.0 install c:\Work\if\server\node_modules\pg
> node-gyp rebuild || (exit 0)


c:\Work\if\server\node_modules\pg>node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\nod
e-gyp.js" rebuild
  binding.cc
..\src\binding.cc(424): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) [c:\Work\if\server\node_module
s\pg\build\binding.vcxproj]
C:\Users\markk.IL-Mark-LT\.node-gyp\0.10.17\deps\v8\include\v8.h(218): warning C4506: no definition for inline function 'v8::Persistent<T>
v8::Persistent<T>::New(v8::Handle<T>)' [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
          with
          [
              T=v8::Object
          ]
     Creating library c:\Work\if\server\node_modules\pg\build\Release\binding.lib and object c:\Work\if\server\node_modules\pg\build\Releas
  e\binding.exp
binding.obj : error LNK2001: unresolved external symbol _PQfreemem [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQflush [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQresultErrorField [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsendQueryParams [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQgetCancel [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQclear [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsocket [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsendQueryPrepared [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQstatus [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQnotifies [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQisnonblocking [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQgetResult [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQputCopyEnd [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQcmdStatus [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsetnonblocking [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQescapeIdentifier [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQfinish [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQisBusy [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQerrorMessage [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQfname [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQntuples [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsendPrepare [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQgetCopyData [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQresultStatus [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsetNoticeProcessor [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQescapeLiteral [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQconnectStart [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQcancel [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQputCopyData [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQfreeCancel [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQgetvalue [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQsendQuery [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQconnectPoll [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQcmdTuples [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQresStatus [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQftype [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQconsumeInput [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQnfields [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
binding.obj : error LNK2001: unresolved external symbol _PQgetisnull [c:\Work\if\server\node_modules\pg\build\binding.vcxproj]
c:\Work\if\server\node_modules\pg\build\Release\binding.node : fatal error LNK1120: 39 unresolved externals [c:\Work\if\server\node_modules
\pg\build\binding.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files (x86)\nodejs\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:789:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Work\if\server\node_modules\pg
gyp ERR! node -v v0.10.17
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok
pg@2.6.0 node_modules\pg
├── generic-pool@2.0.3
└── buffer-writer@1.0.0 (async@0.2.9, cloned@0.0.1)

c:\Work\if\server>path
PATH=c:\windows\system32;c:\windows;C:\Program Files (x86)\Graphviz2.30\bin;C:\Program Files\Calibre2\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\nodejs\;C:\Utils;c:\mongo\bin;c:\Program Files\TortoiseHg\;d:\PostgreSQL\9.2\bin\;c:\Python27\;d:\PostgreSQL\9.2\lib

c:\Work\if\server>

Apparently, the problem is that libpq.lib is not linked and thus there are missing references at the linkage build step.

显然,问题是libpq.lib没有链接,因此在链接构建步骤中缺少引用。

But I am failing to see why the problem exists.

但我没有理解为什么问题存在。

I have run gyp directly with the configure target:

我已经使用configure目标直接运行gyp:

c:\Work\if\server>cd node_modules\pg

c:\Work\if\server\node_modules\pg>node "C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" configure
gyp info it worked if it ends with ok
gyp info using node-gyp@0.10.9
gyp info using node@0.10.17 | win32 | ia32
gyp info spawn python
gyp info spawn args [ 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\Work\\if\\server\\node_modules\\pg\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\markk.IL-Mark-LT\\.node-gyp\\0.10.17\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\markk.IL-Mark-LT\\.node-gyp\\0.10.17',
gyp info spawn args   '-Dmodule_root_dir=c:\\Work\\if\\server\\node_modules\\pg',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'c:\\Work\\if\\server\\node_modules\\pg\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok

c:\Work\if\server\node_modules\pg>

I do not know if I am supposed to see it there, but there are no references to the postgres at all in this output.

我不知道我是否应该在那里看到它,但在这个输出中根本没有提到postgres。

Here is the binding.gyp file (my OS is Windows 7):

这是binding.gyp文件(我的操作系统是Windows 7):

{
  'targets': [
    {
      'target_name': 'binding',
      'conditions' : [
        ['OS=="win"', {
          'conditions' : [
            ['"<!@(cmd /C where /Q pg_config || echo n)"!="n"',
              {
                'sources': ['src/binding.cc'],
                'include_dirs': ['<!@(pg_config --includedir)'],
                'libraries' : ['libpq.lib'],
                'msvs_settings': {
                  'VCLinkerTool' : {
                    'AdditionalLibraryDirectories' : [
                      '<!@(pg_config --libdir)\\'
                    ]
                  },
                }
              }
            ]
          ]
        }, { # OS!="win"
          'conditions' : [
            ['"y"!="n"', # ToDo: add pg_config existance condition that works on linux
              {
                'sources': ['src/binding.cc'],
                'include_dirs': ['<!@(pg_config --includedir)'],
                'libraries' : ['-lpq -L<!@(pg_config --libdir)']
              }
            ]
          ]
        }]
      ]
    }
  ]
}

The configuration should be successful, because:

配置应该成功,因为:

c:\Work\if\server\node_modules\pg>cmd /C where /Q pg_config || echo n

c:\Work\if\server\node_modules\pg>pg_config --includedir
d:/POSTGR~1/9.2/include

c:\Work\if\server\node_modules\pg>pg_config --libdir
d:/POSTGR~1/9.2/lib

c:\Work\if\server\node_modules\pg>

Still something is wrong.

还是有些不对劲。

How do I troubleshoot this issue?

如何解决此问题?

1 个解决方案

#1


4  

Stupid me. My node.js is 32 bits, whereas the postgres is 64 bits. C'est tout!

愚蠢的我。我的node.js是32位,而postgres是64位。 C'est兜售!

#1


4  

Stupid me. My node.js is 32 bits, whereas the postgres is 64 bits. C'est tout!

愚蠢的我。我的node.js是32位,而postgres是64位。 C'est兜售!