react: UnhandledRejection Error: Cannot Find React Package
I’m encountering an unhandled rejection error with the following details:
64.64 unhandledRejection Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/usr/src/app/node_modules/@phosphor-icons/react/dist/node_modules/.pnpm/react@18.2.0/node_modules/react/' imported from /usr/src/app/node_modules/@phosphor-icons/react/dist/node_modules/.pnpm/react@18.2.0/node_modules/react/cjs/react-jsx-runtime.production.min.mjs
64.64 Did you mean to import react/index.js?
64.64 at new NodeError (node:internal/errors:399:5)
64.64 at legacyMainResolve (node:internal/modules/esm/resolve:235:9)
64.64 at packageResolve (node:internal/modules/esm/resolve:876:14)
64.64 at moduleResolve (node:internal/modules/esm/resolve:938:20)
64.64 at defaultResolve (node:internal/modules/esm/resolve:1153:11)
64.64 at nextResolve (node:internal/modules/esm/loader:163:28)
64.64 at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
64.64 at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
64.64 at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
64.64 at link (node:internal/modules/esm/module_job:76:36) {
64.64 type: 'Error',
64.64 code: 'ERR_MODULE_NOT_FOUND'
64.64 }
It seems like the React package is not being found properly. The error suggests that it cannot locate the React package at a specific path. The message also includes a suggestion: “Did you mean to import react/index.js?”
OS: MacOs, Node.js, Docker Stack:
- @phosphor-icons/react version 2.1.4
- Next.js version 13.4.7
- React version 18.2.0
- React-dom version 18.2.0
Global packages:
- Node.js version 18.16.0
- npm version 9.8.1
Any insights or guidance on resolving this issue would be greatly appreciated.
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 12
- Comments: 23 (5 by maintainers)
Hi all, apologies for delay in resolving this! Testing the hypothesis that it is caused by relying on automatic JSX runtime, as @omridevk suggests. I will be pushing some pre-release updates to NPM shortly and would appreciate some help testing, as many of these problems are intractable and arise from specific nuances of project setup.
Yep. It looks to be this. I fixed it by installing the
2.1.3package which was released onnpmbut was never published here on github. It is probably some weird bundling issue but then again why do we even need to shipnode_moduleswith specific react version?@schardev it won’t work (or at least will error and require an additional package to be installed) for users of
react@16and below. There are still tons of apps running 16.8, and I didn’t want to hurt the dev experience there. Impact should really be minimal.