firebase-js-sdk
firebase-js-sdk copied to clipboard
Upgrade from 10.6.0 to 10.7.0 or 10.8.0: no such file or directory, open 'node:stream'
Operating System
Windows
Browser Version
n/a
Firebase SDK Version
10.7.0; 10.8.0
Firebase SDK Product:
Auth, Database, Firestore
Describe your project's tooling
React App, yarn, Jest
Describe the problem
When updating from firebase 10.6.0 to 10.7.0/10.8.0, i get the following error when executing the Jest tests:
ENOENT: no such file or directory, open 'node:stream'
at Runtime.readFile (../../../node_modules/jest-runtime/build/index.js:1987:21)
at Object.
This seems to be related to a change on version 10.7.0:
Replaced node-fetch dependency with the latest version of undici in Node.js SDK builds for Auth, Firestore, Cloud Functions, and Storage. See GitHub issue #7280.
Steps and code to reproduce issue
I''ve created a small project to replicate the problem using firebase 10.8.0 version (all versions from 10.7.0 produce the same error):
- Download and unzip project file: firebase_issue.zip
- Install libs > yarn install
- Run tests > yarn test
Tests will fail with the following error:
ENOENT: no such file or directory, open 'node:stream'
at Runtime.readFile (../../../node_modules/jest-runtime/build/index.js:1987:21)
at Object.
When using version 10.6.0, the tests run successfully.
Hi @PMG-VascoSaavedra, thank you for reaching out to us. I was able to replicate the reported behavior. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.
Thank you!
So the root problem behind things like this is usually that you are trying to run something in a browser environment (or browser-like environment, which should be jsdom for Jest), but you are pulling in the Firebase Node bundle, and not the browser bundle.
The file you want for Jest is node_modules/@firebase/auth/dist/browser-cjs/index.js. The file you are getting is node_modules/@firebase/auth/dist/node/index.js. This is a problem with Jest's resolver looking at the wrong field in package.json, which happens in different ways in different versions of Jest.
In your case, you're using an older version of Jest because you're using react-scripts, which is the engine behind Create React App, which hasn't been updated in a long time and is bringing in an old version of Jest. It seems this version defaults to looking at the main field in a dependency's package.json, which is pointing at the Node bundle for Firebase auth, which is standard.
A couple of possible solutions for you are to either update Jest to a newer version (which might require ejecting from react-scripts), or to modify your Jest config to resolve to the package.json field exports.node.require (which I think is the default for newer versions of Jest). I'm not really sure how to configure that version of Jest so you might have to consult elsewhere.
Thank you for your analysis and feedback.
I'll look into it, and i'll get back to you once i have found a way to correct this issue!
Hey @PMG-VascoSaavedra. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@PMG-VascoSaavedra if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.