-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-scripts bug with peer-deps when locally linked #6579
Comments
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. |
I know this isn't a huge issue, but the problem is a well-defined regression from CRA v1 and imho the workaround I've proposed in #6580 is pretty simple with minimal risk of causing unintended consequences. It'd be a shame if this was auto-closed given that so many people depend on 💕 |
I am the main author behind the popular create-react-library package, and there is currently a bug preventing us from switching to using CRA v2 for the example projects.
This is related to locally linked packages and you may relate it somewhat to monorepo support, but it's such a simple use case, repro scenario, and suggested fix, that I wanted to open an issue for discussion.
Is this a bug report?
Yes.
Did you try recovering your dependencies?
Yes.
node --version
v10.3.0yarn --version
1.13.0Environment
Steps to Reproduce
I created a minimal repro case here.
yarn
at top-level and then also runyarn
in the CRAexample
directory which references the top-level package.react
which is a peer-dependency. This peer-dep is installed as a normal dependency of the CRAexample
, so it exists inexample/node_modules
, but it does not exist in the top-levelnode_modules
.yarn build
oryarn start
from theexample
directory.Expected Behavior
The app should run correctly and display a minimal CRA page with a single component.
Note that this works fine with
CRA v1
and appears to be a regression withCRA v2
.Actual Behavior
You get the following error, even though
react
is installed as a dependency in the CRA package.Reproducible Demo
See https://github.com/transitive-bullshit/react-scripts-link-peer-deps-bug-repro and the repro steps above.
Note that this behavior repros even if you don't use the
link:..
syntax and instead actuallyyarn link
the dependent package. In both cases, yarn is creating a symlink to the package and webpack only tries to resolvereact
from the relativenode_modules
directories, but it does not try to resolvereact
from the app's rootnode_modules
directory which imho is definitely a bug with react-script's webpack config.Note that you can fix this issue by running
NODE_PATH=node_modules yarn start
, which results in this webpack config line containing the full, absolute path topaths.appNodeModules
instead of justnode_modules
as a relative path.For now, I can work around this by adding
NODE_PATH=node_modules
to the create-react-library template, but this should really not be necessary and took me awhile to track down. I will be submitting a PR with my suggested fix shortly.The text was updated successfully, but these errors were encountered: