question-mark
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.

Migrating from v13 to v14 breaks import for `react-hook-form`

See original GitHub issue

Current 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 to 7.29.0
  • Downgrading metro (and related dependencies) to 0.66 or 0.67
  • Removing node_modules entirely and reinstalling dependencies using yarn
  • 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 to nx@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:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
bluebill1049commented, Apr 29, 2022

Let us know if there is anything we would need to adjust.

1reaction
mauriscommented, Apr 29, 2022

cc @bluebill1049 for awareness. this is likely a nx@14 issue since react-hook-form@7.30.0 was working in nx@13

Read more comments on GitHub >

github_iconTop 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 >

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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found