Charley
Charley

Reputation: 15

After updating yarn, react app is failing to compile due to node-module related import error

It was all working ok, then everything changed when I updated yarn. I get this error in the yarn server terminal window: Failed to compile. ./node_modules/react-overlays/esm/Dropdown.js Attempted import error: 'useUncontrolledProp' is not exported from 'uncontrollable'.

and this in the localhost window thing: ./node_modules/react-overlays/esm/Dropdown.js Attempted import error: 'useUncontrolledProp' is not exported from 'uncontrollable'.

I just am lost when it comes to those node modules, and could really use some direction in navigating this unfortunate situation.

Upvotes: 0

Views: 1612

Answers (1)

tenuki
tenuki

Reputation: 180

In my case, the problem seems to be related to react-bootstrap requiring uncontrollable==^7.0.0 and yarn installing that exact version.

I've fixed it by:

  1. yarn add [email protected]
  2. remove node_modules directory: in my case rmdir /q /s node_modules
  3. edit package.json to add this: { "resolutions": "uncontrollable": "7.1.1" } (don't forget the , if it is not the last item)
  4. yarn (to re-install all packages)

The point 3. prevents dependencies to use other versions of uncontrollable according to: https://stackoverflow.com/a/41082766/1033012 .


Extra info:

Also, if I ran: yarn list uncontrollable between step 1 and 2, output was:

yarn list v1.22.4
warning ..\..\..\..\package.json: No license field
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ [email protected]
│  └─ [email protected]
├─ [email protected]
│  └─ [email protected]
└─ [email protected]
Done in 0.90s.

But that was fixed with steps 2 to 4 with leaved system like this: yarn list uncontrollable

yarn list v1.22.4
warning ..\..\..\..\package.json: No license field
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
Done in 0.99s.

Upvotes: 2

Related Questions