Unable to install the node-postgres node.js module

1.2k views Asked by At

Please, observe:

c:\Work\if\server>npm install pg
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] 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

> [email protected] 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
[email protected] node_modules\pg
├── [email protected]
└── [email protected] ([email protected], [email protected])

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.

But I am failing to see why the problem exists.

I have run gyp directly with the configure target:

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 [email protected]
gyp info using [email protected] | 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.

Here is the binding.gyp file (my OS is 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

There are 1 answers

1
mark On

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