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.

Dependency Warning - proper way to implement Yarn Workspace monorepo with CRA with root dependencies?

See original GitHub issue

I am running into an issue when trying to start CRA when I have similar dependencies in the root of my yarn workspace monorepo. I have a .eslintrc in the root of my project along with all of my Eslint/Prettier packages so that all of my projects are able to receive linting/autoformatting.

I just recently added CRA to my monorepo in an attempt to create a new application. This gives me an error message and I did not want to assume that I would not run into any future issues. I am hoping to learn the ideal solution to how to properly use CRA within a yarn workspace monorepo while also being able to have proper linting/autofortmatting via Eslint and Prettier.

Demo repo below.

Is this a bug report?

Maybe Very closely related to https://github.com/facebook/create-react-app/issues/4296. I was unable to decipher a proper solution from this discussion.

Steps to Reproduce

  1. Clone demo repo below
  2. Run yarn to install dependencies
  3. Run yarn workspace my-app start to try to start the application.

Expected Behavior

yarn start succeeds

Actual Behavior

Get error message: capture

Reproducible Demo

https://github.com/clayhan/cra-yarn-test

Thanks for any help!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

1reaction
bugzpoddercommented, Feb 4, 2019

I don’t have a public repo, but if you follow these instructions it should just work:

  1. in your root (workspace) package.json, add the following nohoist option:
     "**/babel-eslint",
     "**/babel-jest",
     "**/eslint",
     "**/jest",
     "**/webpack-dev-server",
     "**/webpack-cli"
   ]```
2) Make sure you don't have any of these packages in your root (workspace) package.json
3) remove node_modules from the worksapce (root)
do another yarn install
4) ensure your new node_modules/ doesn't contain any of these pacakges.  If there is a matching one then your nohoist is wrong.
5) run yarn start in your cra directory and see that the error should go away.

tldr nohoist should not install the specified packages in your root node_modules.
0reactions
stale[bot]commented, Mar 26, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Workspaces - Yarn
Workspaces are a new way to set up your package architecture that's available by default starting from Yarn 1.0. It allows you to...
Read more >
How do I add shared dependencies to a monorepo using Yarn ...
1 Answer 1 · 1. Sync dependency version with syncpack · 2. Use peer dependencies · 3. Share script (require yarn v2) ·...
Read more >
Step by Step Guide to create a Typescript Monorepo with Yarn ...
Step by Step Guide · yarn eject the app · remove node_modules and yarn. · remove files and dependencies related to jest and...
Read more >
React Monorepo Using Yarn Workspaces Only (No Lerna)
Also here we're using the main module as a dependency and will be linked properly when running yarn install . The main module...
Read more >
Corralling Monorepos with Yarn Workspaces - DigitalOcean
To help avoid these kinds of issues, we can treat individual subprojects as their own project, with their own dependencies. To do so,...
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