Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue resolving dependency to `use-force-update` in react-native/expo project

See original GitHub issue

Hey Charles,

I am running into an issue with an Expo/React-Native project resolving the reactn dependency to use-force-update.

I get the following errors (picture, and then error text…)

Screen Shot 2022-07-21 at 12 54 56 PM

iOS Bundling failed 1265ms
While trying to resolve module `use-force-update` from file `/Users/m4ttheweric/Documents/GitHub/mbmd-expo/node_modules/reactn/build/use-dispatch.js`, the package `/Users/m4ttheweric/Documents/GitHub/mbmd-expo/node_modules/use-force-update/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/m4ttheweric/Documents/GitHub/mbmd-expo/node_modules/use-force-update/dist/cjs/index.cjs`. Indeed, none of these files exist:

  * /Users/m4ttheweric/Documents/GitHub/mbmd-expo/node_modules/use-force-update/dist/cjs/index.cjs(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
  * /Users/m4ttheweric/Documents/GitHub/mbmd-expo/node_modules/use-force-update/dist/cjs/index.cjs/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)

I was able to resolve it by making a small change to the package.json to use-force-update within the node_modules dir.


  "main": "./dist/cjs/index.cjs"


  "main": "./dist/esm/index.js"

Any ideas on why this is occurring? I’m not familiar with the cjs/esm setup you’re using, so I don’t want to comment as to whether my solution is “good”.


Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

CharlesStovercommented, Jul 22, 2022

This looks like an issue with “MetroJS bundler” not supporting .cjs extensions natively.

Looks like you need to edit your existing metro.config.js file (or make one if it does not already exist), then add cjs to the resolver.sourceExts array.

Let me know if the above StackOverflow solutions don’t unblock you. I can see what else I can do, but I am ultimately relunctant to change the file extension of the bundled CommonJS file, because the different file extension is a requirement for newer versions of Node to distinguish CommonJS from ESM files in the same package.

minuitagencycommented, Aug 10, 2022

Hi Charles,

Thanks for the library, could you release an update to reactn that has the fixed use-force-update dependency ? We use reactn in a LOT of projects…



Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found