Postgraphile: Error: Cannot find module 'graphile-build-pg'

Created on 19 Jun 2018  路  8Comments  路  Source: graphile/postgraphile

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] question

PostGraphile version: 4.0.0-rc.1 or whatever npm install -g postgraphile is handing out these days.

Running command via a Docker file. Has been working flawlessly for months. Something about the update has it messed up.

postgraphile -n 0.0.0.0 -c postgres://$USER:$PASS@$HOST:$PORT/$DB -o -a -j -M --append-plugins /plugins/connection-filter/index.js

Getting this output

Error: Cannot find module 'graphile-build-pg'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/plugins/connection-filter/src/PgConnectionArgFilterPlugin.js:1:80)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)

Happy to provide any further helpful information. Seems like it could likely be an easy fix.

Most helpful comment

@garretteklof I suggest you use yarn to install your dependencies, and then run npx yarn-deduplicate && yarn. That tends to fix issues like this.

All 8 comments

Solved. Sort of.

I had to manually add graphile-build-pg, graphql and pg to my Dockerfile.

npm install -g postgraphile && \
npm install graphile-build-pg && \
npm install graphql && \
npm install pg && \

Seems odd those aren't included with the postgraphile package, but maybe this is intentional?

They鈥檙e included via postgraphile-core; it should work... are you able to share your dockerfile? The official graphile/postgraphile docker image was working last I checked.

Ah; this isn't an issue with PostGraphile - it's with postgraphile-plugin-connection-filter and specifically it's an issue because postgraphile-plugin-connection-filter requires graphile-build-pg but that's not available to it from where it's installed.

I've filed a PR against your repo: https://github.com/TinyAnvil/postgraphile-docker/pull/1

Thanks for your support on Patreon 馃檹

Thanks @benjie! Works like a charm now.

Hi Benjie - I'm going to leave this here as opposed to opening a new issue. I'm currently running into something similar. I'm unable to isolate where it's coming from (one of the plugins or postgraphile-apollo-server, which I am also using). If I explicitly add the graphile-build-pg dependency the server works as expected. I blindly updated postgraphile and related plugins, but when I reverted back the error was still there. I think this has to do with me deleting my old node_modules in the process. Somewhere along the line the dependency must have snuck in there? Still not sure why it's explicitly needed if it's included via core. Any insight on this would be greatly appreciated! Thanks.

Screen Shot 2020-03-28 at 4 07 09 PM

"@graphile-contrib/pg-simplify-inflector": "^5.0.0-beta.1", "@graphile/postgis": "^0.1.0", "postgraphile": "^4.6.0", "postgraphile-apollo-server": "^0.1.1", "postgraphile-plugin-connection-filter": "^1.1.3", "postgraphile-plugin-connection-filter-postgis": "^1.0.0-alpha.5",

@garretteklof I suggest you use yarn to install your dependencies, and then run npx yarn-deduplicate && yarn. That tends to fix issues like this.

Cool - yarn deduplicate worked. Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings