react-error-boundary: Can't find module entry since v6

Hi! I’m trying to build without success my app with the v6 but the bundler seems to don’t find the entry :

 ERROR  Error: While trying to resolve module `react-error-boundary` from file `/Users/user/core/src/components/ErrorBoundaryCatcher/ErrorBoundaryCatcher.tsx`, the package `/Users/user/core/node_modules/react-error-boundary/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/user/core/node_modules/react-error-boundary/index`.

Any idea?

It is a react-native project.

Thank you.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 7
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I had this issue too when using Parcel. I had to enable packageExports for the resolver. I thought this was strange as I’ve never had an issue with any package in the last couple years with Parcel. I’m guessing most libraries use both exports and the main field.

For anyone wondering, the change log says that the only change between v5 and v6 is using ESModules + Exports. So yes, sticking with v5 is a totally viable approach.

I’m having the same issue but with a standard react web app.

Hello guys,

I’ve spent some time on that and looks like react-error-boundary works just fine. The problem is how eslint-plugin-import (rule import/no-unresolved) reacts on ES-only modules. I mean, UNLESS your project supports ES modules. See https://github.com/import-js/eslint-plugin-import/issues/2331#issuecomment-997417550. So, the way to make eslint-plugin-import not to complain is to add ES-only packages to the ignore list.

      'import/no-unresolved': [2, { caseSensitive: true, ignore: ['^react-error-boundary$'] }],

Possibly there are alternatives for eslint-plugin-import, but I haven’t dug into it yet.

Yeah @TomCorvus, that’s unfortunate. But in this case you aren’t missing out on anything by sticking with version 5. Same features. This package has been stable for a long time, feature wise.

Hello, same here on standard react app project.

import { ErrorBoundary } from 'react-error-boundary'

Unable to resolve path to module ‘react-error-boundary’.eslint import/no-unresolved

It seems that Hermes doesn’t support natively ESM. On my side, I need to modify Metro config and enable unstable_enablePackageExports like this:

config.resolver.unstable_enablePackageExports = true

Maybe one day: https://github.com/facebook/hermes/discussions/1391