TypeError: Pool is not a constructor when using Postgre SQL as storage type
matusnovak opened this issue · 6 comments
I am getting the following error when I try to use postgres
as STORAGE_TYPE
. The error is the following:
> haste@0.1.0 start /usr/src/app
> node server.js
/usr/src/app/lib/document_stores/postgres.js:13
this.pool = new Pool({connectionString});
^
TypeError: Pool is not a constructor
at new PostgresDocumentStore (/usr/src/app/lib/document_stores/postgres.js:13:15)
at Object.<anonymous> (/usr/src/app/server.js:54:20)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! haste@0.1.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the haste@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Steps to reproduce the problem. You don't need to provide other STORAGE_*
environment variables, nor to run a postgres docker container, to reproduce this problem.
git clone https://github.com/seejohnrun/haste-server.git
cd haste-server
docker build . -t seejohnrun/haste-server:latest
docker run --rm --name haste -e STORAGE_TYPE=postgres -it seejohnrun/haste-server:latest
# Fails with the error from above
It looks like this stackoverflow post is relevant: https://stackoverflow.com/questions/56647673/unable-to-create-a-pool-instance-with-constructor-in-jest-test
Hi there @matusnovak
I was able to duplicate your issue.
I was able to fix it by modifying the Docker file to use pg 8.0.1. I didn't perform extensive testing to determine how new I could go with the PG module but I saw in the commit messages that the code was modified for PG 8 so i just went with a very early release.
`- npm install pg@4.1.1 && \
- npm install pg@8.0.1 &&
`
Yeah, if I change that in the Dockerfile that seems to fix it, thanks!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
If possible, please update the Dockerfile, so this is more user-friendly