TypeError: User is not a constructor in @pubsweet/db-manager/src/commands/add-user.js
Describe the bug
Hello, we are attempting to launch the @coko/server
using the startServer
method, but it always fails to connect to the running database during the startup sequence. I believe I've narrowed down the issue to the db-manager, which fails with:
TypeError: User is not a constructor at module.exports (/workspace/coko-server-test/node_modules/@pubsweet/db-manager/src/commands/add-user.js:11:16) at module.exports (/workspace/coko-server-test/node_modules/@pubsweet/db-manager/src/commands/setup-db.js:17:11) at async seed (/workspace/coko-server-test/index.js:10:3)
Steps To Reproduce
I have setup a test project at drkstr101/coko-server-test that demonstrates the issue in the CI pipeline. Here is an expert from the last failed job:
Run node . Loaded Config: { 'pubsweet-server': { db: { user: 'postgres', host: 'db', database: 'test', password: 'postgres', port: 5432 } }, dbManager: { username: 'admin', password: 'password', email: 'admin@example.com', admin: true, clobber: true } } Setting up the database [ '== 1524494862-entities: migrating =======' ] Successfully ran migration 1524494862-entities.sql [ '== 1524494862-entities: migrated (0.008s)\n' ] Creating user admin Database setup failed Trace: TypeError: User is not a constructor at module.exports (/__w/coko-server-test/coko-server-test/node_modules/@pubsweet/db-manager/src/commands/add-user.js:11:16) at module.exports (/__w/coko-server-test/coko-server-test/node_modules/@pubsweet/db-manager/src/commands/setup-db.js:17:11) at async seed (/__w/coko-server-test/coko-server-test/index.js:10:3) at /__w/coko-server-test/coko-server-test/index.js:35:11 Error: Process completed with exit code 1.
I have also tried this by adding @pubsweet/models
, @pubsweet/db-manager
, and pubsweet-server
directly with the same results.
Expected behavior
Running the script should seed the database without issue.
Screenshots
If applicable, add screenshots to help explain your problem.
Device, Operating System and Browser
Tested in node 14, 16, 18 on both linux (GitPod) and alpine (CI) platforms.
Thanks for your time!