2
votes

Recently I encountered the above error (TypeError: module.exports.v1 is not a constructor) when trying to run firebase-firestore related tests. Earlier I had no issue running the tests but after doing a npm install was getting the above error. The source of the error is from google-cloud/firestore which is required by firebase-admin. Tried several options but it doesn't seems to get resolved. I then tried with an older node-module and it worked as expected.

3
Possibly a corrupted node_modules directory? Have you tried deleting it (and the package lock file) and reinstalling the dependencies?Hiranya Jayathilaka
yes did all the possible stuff. tried with deleting both package-lock and node-modules but the problem still existsSupun Muthutantrige

3 Answers

1
votes

The problem was due to the test framework I've been using. Once I changed from jest to mocha the problem got solved.

1
votes

When I updated firebase admin sdk from 8.4.0 to higher then I had same error in running jest test code.

I fixed it to add --env node option for jest.

jest --env node

0
votes

We needed to upgrade node from v8.11.3 to v8.16.2.