Native binding not loading
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.
Looking in the node_modules directly, I'm not seeing the /build/default/binding/—is that something that can be build using a script?
:+1:
Once you installed the build dependency (libpq-dev) you should be able to compile this via a simple npm install pg.
closing due to inactivity
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?
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?
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.
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])
What version of node are you using?
~/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.
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
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.
Node version: 0.10.21 Pg version: 2.8.3 npm version: 1.3.11 OS: Windows 32bit 7 Ultimate
Thank you in advance!
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.
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 you might want to bug the sequelize team to update their node-postgres dependency. [email protected] is really old.
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
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"
}
}
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:
gypfailed 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/pgI'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 .
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.
Yup, was my conflicting node installations. Sorry about that - I really need to watch for redundant installs :angry:
@iToto if you're using postgres installed from postgres.app there are some weird gotchas with pg_config
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 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!