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.

verifyPackageTree() errors when wrong version dependency is installed in any parent directory

See original GitHub issue

Is this a bug report?


Did you try recovering your dependencies?

No. This issue presents an argument that there may be a bug in the verifyPackageTree.js logic added in the next branch.

Which terms did you search for in User Guide?

version, dependenc. This does not appear to be documented (and since it is internal, maybe it shouldn’t be). There is discussion regarding documenting some of the packages related to this in issue in issue #4137 (suggested by @Timer here).


$ node -v

$ npm -v

$ yarn --version

Running on macOS 10.13.2.

Steps to Reproduce

I created a reproduction project here:

The project is a simple node package that depends on a version of jest that is incompatible with create-react-app@2.0.0-next.47d2d941. The project also contains a directory (cra-app) that was generated by create-react-app. The react-scripts dependency in that sub-project has been updated to 2.0.0-next.47d2d941.

  1. git clone
  2. cd create-react-app-issue-4167
  3. yarn
  4. yarn run

Expected Behavior

From a user perspective, the yarn run command should not error and the application should start. The user did not manually install an incompatible version of jest in the create-react-app generated project. The version of jest in the generated project’s node_modules is the correct version and parent directories should not have an impact.

From a technical perspective, the verifyPackageTree.js logic should see that the cra-app project contains the correctly installed version of jest and stop checking parent directories. Parent directories should only be traversed if jest is not installed.

Actual Behavior

An error occurs because parent directory depends on a version of jest that is incompatible with the version of jest that create-react-app generated project depends on.

Reproducible Demo

Edit: Updated the issue number on the links.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:23
  • Comments:27 (7 by maintainers)

github_iconTop GitHub Comments

newogacommented, Feb 4, 2019

@Timer I don’t fully understand the concern with hoisting based on your example here, assuming I am not misunderstanding how yarn’s hoisting works.

I recreated the example in a new branch. You were right that since webpack@3 is required more than webpack@4, webpack@3 is hoisted to the root directory. However, webpack@4 is still installed “locally” in the node_modules directory for the one package/workspace that depends on it.

Based on this hoisting behavior, create-react-app should not need to traverse and validate versions of the dependencies in all parent directories. It should only need to validate versions for the first occurrence of each dependency when traversing up the directory hierarchy (in order to mimic node’s package resolution behavior).

Let me know if I’m misunderstanding the problem we are trying to avoid/protect end users from.

Edit: tl;dr; Are we sure we cannot (1) Trust yarn to hoist dependencies properly in a way that does not impact create-react-app, and (2) Change verifyPackageTree() validation logic to only validate the dependencies that would actually be resolved by node’s package resolution logic?

Timercommented, Dec 26, 2018

I agree we can make this smarter – maybe we can try to detect when in a workspace/monorepo and bail out once we hit the root of the workspace.

Read more comments on GitHub >

github_iconTop Results From Across the Web

create-react-app dependency version issues with React 18
Here is a temporary workaround: Install cra-template to a separate folder (other than your new project app's folder) using "npm install cra- ...
Read more >
Spring Boot, Maven and Eclipse Errors and TroubleShooting ...
First of all - Make sure you are using the right versions. Here is the recommended versions and errors if you don't use...
Read more >
NPM Dependency errors? Then You're doing it wrong. - Medium
The Problem with non-deterministic dependencies. You set up a new Node JS/Webpack project, installed all your dependencies with npm install and your app...
Read more >
react-scripts parent folder node_modules error when running ...
With storybook installed (requiring version ^8.0.0 ), we get a different babel-loader in the top level node_modules so that we end up with:...
Read more >
react-scripts: Versions - Openbase
NOTE: You may need to delete your node_modules folder and reinstall your dependencies by running npm install (or yarn ) if you encounter...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found