簡體   English   中英

無法安裝node-postgres node.js模塊

[英]Unable to install the node-postgres node.js module

請觀察:

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>

顯然,問題是libpq.lib沒有鏈接,因此在鏈接構建步驟中缺少引用。

但我沒有理解為什么問題存在。

我已經使用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>

我不知道我是否應該在那里看到它,但在這個輸出中根本沒有提到postgres。

這是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)']
              }
            ]
          ]
        }]
      ]
    }
  ]
}

配置應該成功,因為:

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>

還是有些不對勁。

如何解決此問題?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM