node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Native binding not loading

Open mudcube opened this issue 13 years ago • 21 comments

When switching from require('pg') to require('pg').native Node creates this error:

mud:sketch-src mud$ node server.js

Error: Cannot find module '/Library/WebServer/Documents/sketchpad.io/sketch-src/node_modules/pg/lib/native/../../build/default/binding' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object. (/Library/WebServer/Documents/sketchpad.io/sketch-src/node_modules/pg/lib/native/index.js:12:12) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:362:17)

Looking in the node_modules directly, I'm not seeing the /build/default/binding/—is that something that can be build using a script?

mudcube avatar Dec 23 '12 23:12 mudcube

:+1:

frolic avatar Jan 09 '13 05:01 frolic

Once you installed the build dependency (libpq-dev) you should be able to compile this via a simple npm install pg.

booo avatar Jan 09 '13 11:01 booo

closing due to inactivity

brianc avatar Jan 14 '13 21:01 brianc

I ran sudo apt-get install libpq-dev then I ran npm install pg and I still get the same error as mudcube. Any ideas on resolving this error?

tapatio avatar Apr 21 '13 00:04 tapatio

When you install the pg module it will invoke node-gyp to compile the native bindings. This compilation process will spit out errors if the compile fails, but the install will still continue so you can use the pure-javascript bindings. Can you provide the output from the npm install pg command with the lines from node-gyp?

brianc avatar Apr 21 '13 17:04 brianc

I am on pg version 2.8.3 on ubuntu. The build works fine - no errors, but when I try and use the native bindings I get the following:

var pg = require('pg').native;

Error: Cannot find module '/home/chyld/Desktop/compozr/server/node_modules/pg/lib/native/../../build/default/binding' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (/home/chyld/Desktop/compozr/server/node_modules/pg/lib/native/index.js:17:13) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

This is a log of the npm install pg

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 304 https://registry.npmjs.org/cloned/0.0.1 npm http GET https://registry.npmjs.org/rmdir npm http 304 https://registry.npmjs.org/rmdir

[email protected] install /home/chyld/Desktop/compozr/server/node_modules/pg node-gyp rebuild || (exit 0)

make: Entering directory /home/chyld/Desktop/compozr/server/node_modules/pg/build' CXX(target) Release/obj.target/binding/src/binding.o SOLINK_MODULE(target) Release/obj.target/binding.node SOLINK_MODULE(target) Release/obj.target/binding.node: Finished COPY Release/binding.node make: Leaving directory/home/chyld/Desktop/compozr/server/node_modules/pg/build' [email protected] node_modules/pg ├── [email protected] └── [email protected] ([email protected])

chyld avatar Nov 24 '13 20:11 chyld

What version of node are you using?

brianc avatar Nov 25 '13 15:11 brianc

~/Desktop/compozr/server > node --version v0.10.22

It works fine if I use the JS driver, it's when I switch to the native driver where the problem arises.

chyld avatar Nov 25 '13 17:11 chyld

I have the same problem with native, please help:

npm http GET https://registry.npmjs.org/pg npm http 304 https://registry.npmjs.org/pg npm http GET https://registry.npmjs.org/buffer-writer/1.0.0 npm http GET https://registry.npmjs.org/generic-pool/2.0.3 npm http 304 https://registry.npmjs.org/buffer-writer/1.0.0 npm http 304 https://registry.npmjs.org/generic-pool/2.0.3 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 D:\node\docs\node_modules\pg node-gyp rebuild || (exit 0)

D:\node\docs\node_modules\pg>node "D:\nodejs\node_modules\npm\bin\node-gyp-bin
....\node_modules\node-gyp\bin\node-gyp.js" rebuild binding.cc ..\src\binding.cc(211): warning C4800: 'int32_t' : forcing value to bool 'true' or 'false' (performance warning) [D:\node\docs\node_modules\pg\build\binding.v cxproj] ..\src\binding.cc(243): warning C4800: 'int32_t' : forcing value to bool 'true' or 'false' (performance warning) [D:\node\docs\node_modules\pg\build\binding.v cxproj] ..\src\binding.cc(284): warning C4800: 'int32_t' : forcing value to bool 'true' or 'false' (performance warning) [D:\node\docs\node_modules\pg\build\binding.v cxproj] ..\src\binding.cc(452): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) [D:\node\docs\node_modules\pg\build\binding.vcxpr oj] C:\Users\qu1ze.node-gyp\0.10.21\deps\v8\include\v8.h(218): warning C4506: no d efinition for inline function 'v8::Persistent v8::Persistent::New(v8::Han dle)' [D:\node\docs\node_modules\pg\build\binding.vcxproj] with [ T=v8::Object ] Creating library D:\node\docs\node_modules\pg\build\Release\binding.lib an d object D:\node\docs\node_modules\pg\build\Release\binding.exp Generating code Finished generating code binding.vcxproj -> D:\node\docs\node_modules\pg\build\Release\binding.node [email protected] node_modules\pg ├── [email protected] └── [email protected] ([email protected], [email protected])

Then when I'm trying "node app.js" I get

Error: Cannot find module 'D:\node\docs\node_modules\pg\lib\native/../../build/d efault/binding' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (D:\node\docs\node_modules\pg\lib\native\index.js:17:1 3) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)

Node version: 0.10.21 Pg version: 2.8.3 npm version: 1.3.11 OS: Windows 32bit 7 Ultimate

Thank you in advance!

olegmdev avatar Nov 29 '13 00:11 olegmdev

I am seeing of manifestation of this bug as well. Let me know if I can help debug.

I need it to connect externally to heroku via ssl.

matzipan avatar Dec 27 '13 22:12 matzipan

I need to mention that I'm using 0.10. Because that's sequelize-postgres 1.6.0's dependency.

2 latest node-pg version works fine.

matzipan avatar Dec 28 '13 13:12 matzipan

@matzipan you might want to bug the sequelize team to update their node-postgres dependency. [email protected] is really old.

brianc avatar Dec 29 '13 21:12 brianc

Optionally you could ask them to use node-postgres as a peer dependency instead of a regular dependency. Then you could manage which version of node-postgres you wanted to install

brianc avatar Dec 29 '13 21:12 brianc

I'm also seeing this error but noticed that gyp is throwing an error when trying to compile.

/bin/sh: pg_config: command not found
gyp: Call to 'pg_config --libdir' returned exit status 127. while trying to load binding.gyp
npm http GET https://registry.npmjs.org/async
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/Cellar/node/0.10.15/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:424:16)
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 Darwin 13.0.0
gyp ERR! command "node" "/usr/local/Cellar/node/0.10.15/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/me/project/node_modules/pg
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.10.6
gyp ERR! not ok
npm http 304 https://registry.npmjs.org/source-map
npm http 304 https://registry.npmjs.org/optimist
[email protected] node_modules/pg

I'm trying to get this to build so that I can deploy an application. Any idea what I should try to get it to compile? Here is my package.json

{
    "name": "project"
  , "version": "0.1.0"
  , "private": true
  , "engines": {
      "node": "0.10.26",
      "npm": "1.3.5"
    }
  , "dependencies": {
    "express": "3.2.6"
    , "pg"          : "2.10.x"
    , "less"        : ">= 0.0.1"
    , "jade"        : ">= 0.0.1"
    , "mandrill-api":"latest"
  }
}

iToto avatar Jan 02 '14 15:01 iToto

What version of node & postgres are you using?

What does running pg_config --libdir return to you via the command line?

On Thu, Jan 2, 2014 at 9:15 AM, iToto [email protected] wrote:

I'm also seeing this error but noticed that gyp is throwing an error when trying to compile.

/bin/sh: pg_config: command not found gyp: Call to 'pg_config --libdir' returned exit status 127. while trying to load binding.gyp npm http GET https://registry.npmjs.org/async gyp ERR! configure error gyp ERR! stack Error: gyp failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/Cellar/node/0.10.15/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:424:16) 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 Darwin 13.0.0 gyp ERR! command "node" "/usr/local/Cellar/node/0.10.15/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/me/project/node_modules/pg gyp ERR! node -v v0.10.24 gyp ERR! node-gyp -v v0.10.6 gyp ERR! not ok npm http 304 https://registry.npmjs.org/source-map npm http 304 https://registry.npmjs.org/optimist [email protected] node_modules/pg

I'm trying to get this to build so that I can deploy an application. Any idea what I should try to get it to compile? Here is my package.json

{ "name": "project" , "version": "0.1.0" , "private": true , "engines": { "node": "0.10.26", "npm": "1.3.5" } , "dependencies": { "express": "3.2.6" , "pg" : "2.10.x" , "less" : ">= 0.0.1" , "jade" : ">= 0.0.1" , "mandrill-api":"latest" }}

— Reply to this email directly or view it on GitHubhttps://github.com/brianc/node-postgres/issues/231#issuecomment-31458468 .

brianc avatar Jan 02 '14 16:01 brianc

node => 0.10.26 node-pg => 2.10.x postgres => 9.1.9 (heroku)

I just noticed that I may have two copies of node installed (one from npm and the other with brew). I'm sorting that out now and going to see if it solves the issue.

iToto avatar Jan 02 '14 16:01 iToto

Yup, was my conflicting node installations. Sorry about that - I really need to watch for redundant installs :angry:

iToto avatar Jan 02 '14 18:01 iToto

@iToto if you're using postgres installed from postgres.app there are some weird gotchas with pg_config

brianc avatar Jan 02 '14 18:01 brianc

basically postgres.app doesn't modify your path appropriately to give you access to libpq header files and stuff. I usually brew install postgres or build it by source on os x because of that. I do love the ease of postgres.app though.

brianc avatar Jan 02 '14 18:01 brianc

@brianc I totally agree with the ease of the app, but I think I'll switch to brew for postgres to clean things under the same roof. Thanks again for the help!

iToto avatar Jan 03 '14 18:01 iToto