Node.js core modules errors on Metro bundle
Hello,
I'm working on upgrading my react native application to use React Native 0.79.3, React 19, and Expo 53.
When I upgraded to 0.79.3 and React 19, I ran into this error:
error Unable to resolve module util from /../../../../node_modules/contentful/dist/contentful.cjs: util could not be found within the project or in these directories:
node_modules
268 |
269 | var Stream$2 = require$$0$1.Stream;
> 270 | var util$3 = require$$1;
| ^^^^^^^^^^^^^^^^^^^
271 | var delayed_stream = DelayedStream$1;
272 | function DelayedStream$1() {
273 | this.source = null;.
I'm on Contentful version ^11.7.0 and was prior to this upgrade so not sure why this is an issue now.
Update: I believe this is related to: https://github.com/expo/expo/discussions/36551
Since when I added unstable_enablePackageExports: false, my metro bundler began passing without the error above.
Hello @dmonserr, thanks for raising this. Based on your comment, do you believe there is still an issue in the contentful.js package? Or does the issue lay solely in expo?
No, it is an issue with contentful.js - it's not compatible with the newest versions of Metro/Expo/RN.
You guys need to add support for the newer versions.
See https://metrobundler.dev/docs/configuration/#unstable_enablepackageexports-experimental @ethan-ozelius-contentful
Thank you for the report. We found issues with react-native while converting our contentful-managment.js to ESM. We are currently working on a fix there and will then backport this fix to contentful.js
So soon we will support latest expo/metro/react-native. Stay tuned!
This is great news @axe312ger ! Will this be available in v12? Or can you update this thread when it's on a stable branch?