Migrating from v13 to v14 breaks import for `react-hook-form`
See original GitHub issueCurrent Behavior
After performing a migration from v13 to v14 using nx migrate
command, the bundle and build commands for my react-native
app failed with the error:
Error: While trying to resolve module `react-hook-form` from file `<workspaceRoot>\packages\ui\src\lib\login\login.tsx`, the package `<workspaceRoot>\node_modules\react-hook-form\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`<workspaceRoot>\node_modules\react-hook-form\dist\index.cjs.js`. Indeed, none of these files exist:
* <workspaceRoot>\node_modules\react-hook-form\dist\index.cjs.js(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
* <workspaceRoot>\node_modules\react-hook-form\dist\index.cjs.js\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.svg|.native.svg|.svg)
<stacktrace as follow>
The metro.config.js
(specifically sourceExts
) was not modified from default generated.
Things I have tried, but did not work:
- Downgrading
react-hook-form
to7.29.0
- Downgrading
metro
(and related dependencies) to0.66
or0.67
- Removing
node_modules
entirely and reinstalling dependencies usingyarn
- Perform
nx reset
- Clear metro cache in temp dir
The only way to make it work:
- Reverting my monorepo to the commit prior to
nx migrate
(i.e. downgrading back tonx@13
)
Expected Behavior
I expect to be able to bundle and build without module resolution errors.
Steps to Reproduce
I have a monorepo at nx@13.10.2
. After migrating to v14 using nx migrate
, the build and bundle commands failed for react-native
app.
Failure Logs
Nil
Environment
> NX Report complete - copy this into the issue template
Node : 16.14.2
OS : win32 x64
yarn : 1.22.18
nx : 13.10.2
@nrwl/angular : Not Found
@nrwl/cypress : 13.10.2
@nrwl/detox : 13.10.2
@nrwl/devkit : 13.10.3
@nrwl/eslint-plugin-nx : 13.10.2
@nrwl/express : 13.10.3
@nrwl/jest : 13.10.2
@nrwl/js : 13.10.2
@nrwl/linter : 13.10.2
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 13.10.2
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 13.10.3
@nrwl/react-native : 13.10.3
@nrwl/schematics : Not Found
@nrwl/storybook : 13.10.3
@nrwl/web : 13.10.2
@nrwl/workspace : 13.10.2
typescript : 4.6.3
rxjs : 6.6.7
---------------------------------------
Community plugins:
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
Migrate From V6 to V7 - Simple React forms validation
Hi there,. React Hook Form focus on the following aspect on Version 7: (DX) Strict typed form. Reduce package size. Performance enhancements.
Read more >React v0.14 – React Blog
Breaking changes · The props object is now frozen, so mutating props after creating a component element is no longer supported. In most...
Read more >React Hook Form vs. Formik: A technical and performance ...
Compare the technical and performance differences between Formik and the React Hook Form to see which form builder is right for you.
Read more >The Guide to Learning React Hooks (Examples & Tutorials)
We will start by extracting this code into a Hook locally on the same page, and then see how the same Hook can...
Read more >Next.js 13 Upgrade Guide
We recommend reducing the combined complexity of these updates by breaking down your migration into smaller steps. The app directory is intentionally designed ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Let us know if there is anything we would need to adjust.
cc @bluebill1049 for awareness. this is likely a
nx@14
issue sincereact-hook-form@7.30.0
was working innx@13