Skip to content

Cannot find module '[snip]node_modules/pg/lib/native/../../build/default/binding' #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lucasgonze opened this issue May 15, 2012 · 12 comments

Comments

@lucasgonze
Copy link

$ cat package.json 
{ "name": "pg",
  "version": "0.6.17",
...snip

$ node -v
v0.6.11

$ uname -a
Darwin March-1-2012-Air.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64

$ node exampleapp.js 

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module '[...snip]/node_modules/pg/lib/native/../../build/default/binding'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object.<anonymous> (/[...snip]/node_modules/pg/lib/native/index.js:12:12)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Module.require (module.js:354:17)

    $ ls node_modules/pg/build/
    Release     c4che       config.log
@lucasgonze
Copy link
Author

Workaround:

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

@brianc
Copy link
Owner

brianc commented May 15, 2012

Yeah. I'm guessing the npm install of the package failed to build the native bindings properly. Do you have a log from when you did npm install of the package? I'm guessing you're missing a postgres library header or something & it's not building. So then you go to load the native module and it can't find the release folder and fails. I do agree that error message could be better.

@lucasgonze
Copy link
Author

Here is a fresh build log from NPM:

> [email protected] install /Users/herokudev/repro/node_modules/pg
> node-waf configure build || (exit 0)

npm http GET https://registry.npmjs.org/formidable
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /usr/local 
Checking for program pg_config           : /usr/bin/pg_config 
'configure' finished successfully (0.287s)
Waf: Entering directory `/Users/herokudev/repro/node_modules/pg/build'
[1/2] cxx: src/binding.cc -> build/Release/src/binding_1.o
[2/2] cxx_link: build/Release/src/binding_1.o -> build/Release/binding.node
Waf: Leaving directory `/Users/herokudev/repro/node_modules/pg/build'
'build' finished successfully (1.401s)
npm http 304 https://registry.npmjs.org/formidable
[email protected] ./node_modules/pg 
└── [email protected]
[email protected] ./node_modules/express 
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

@brianc
Copy link
Owner

brianc commented Jun 27, 2012

are you still having this issue? the build system changed from waf to gyp.

@karmaon
Copy link

karmaon commented Jun 29, 2012

I'm at 0.7.2 and can confirm I still have this issue.

Edit: Now receiving seg faults as outlined in issue #136

@lucasgonze
Copy link
Author

Retested with node v0.8.1 and could not reproduce.

@brianc
Copy link
Owner

brianc commented Jul 5, 2012

cool - glad this isn't an issue anymore. I'm focusing on #136 now

@brianc brianc closed this as completed Jul 5, 2012
@jjmartin540
Copy link

I'm having this issue on windows 7, 64-bit with the 32-bit version of node and the 32-bit version of postgresql. I have libpq installed and I checked that it was in the PATH. I tried copying libpq.dll to the same folder as binding.node to no avail. At first the native extension didn't build so I installed VSC++ 2010 and then it built. It still refuses to load however with the same stack trace as above (except the windows equivalent.

This is with node 0.8.14 and pg version 0.8.7. The version of postgresql is 9.2.1 (latest stable as of this writing)

$ node index.js

Error: Cannot find module 'C:\Users[snip...][project folder]\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. (C:\Users[snip...][project folder]\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)

After installing VS2010 I got this output:

$ npm rebuild pg

[email protected] install C:\Users\eohcnf5\Documents\nodeMUCode\node_modules\pg
node-gyp rebuild || (exit 0)

C:\Users[snip..][project folder]\node_modules\pg>node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild
binding.cc
..\src\binding.cc(311): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) [C:\Users[snip..][project folder]\node_modules\pg\build\binding.vcxproj]
Creating library C:\Users[snip ..][project folder]\node_modules\pg\build\Release\binding.lib and object >C:\Users[snip..][project folder]\node_modules\pg\build\Release\binding.exp
Generating code
Finished generating code
binding.vcxproj -> C:\Users[snip..][project folder]\node_modules\pg\build\Release\binding.node
[email protected] C:\Users[snip..][project folder]\node_modules\pg

The error when I ran my code was the same as above, however.

Note that just as in the bug above, removing the ".native" from my require "resolves" the issue, it only happens when trying to use the native bindings. As it seems like it might be related to this bug I commented here.

@minitech
Copy link

Getting this on Node 0.10.0/0.8.20 and pg 0.8.8, 64-bit Arch Linux. npm rebuild pg gives an ENOENT; node-gyp rebuild --python=python2 in node_modules/pg works but doesn’t change anything. If that helps any :)

@brianc
Copy link
Owner

brianc commented Mar 15, 2013

You're using pg version 0.8.8? I believe that's a pretty old version.

@avinashega
Copy link

Install postgresql on your machine before installing pg

@jchan172
Copy link

I have the same problem as the OP, except I was on 0.10.26. Installing postgresql did the trick. Thanks @avinashega!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants