Skip to content

Commit 40bb89c

Browse files
Workaround yarn workspace bug not creating app/node_modules/.bin link for react-scripts.
1 parent 69d822c commit 40bb89c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/react-scripts/scripts/init.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const { defaultBrowsers } = require('react-dev-utils/browsersHelper');
2323
const os = require('os');
2424
const resolveFrom = require('resolve-from');
2525
const paths = require('../config/paths');
26+
const { findMonorepo } = require('react-dev-utils/workspaceUtils');
2627

2728
function isInGitRepository() {
2829
try {
@@ -177,10 +178,18 @@ module.exports = function(
177178
fs.unlinkSync(templateDependenciesPath);
178179
}
179180

181+
// yarn ws bug not creating app/node_modules/.bin link to hoisted react-scripts
182+
// -- workaround: install react-scripts again to create link
183+
// bug in yarn 1.3.2, fixed in nightly 1.4.1-20180211.2236
184+
const rerunYarn = useYarn && findMonorepo(appPath).isAppIncluded;
185+
if (rerunYarn) {
186+
console.log('Detected app in yarn workspace, running install again');
187+
}
188+
180189
// Install react and react-dom for backward compatibility with old CRA cli
181190
// which doesn't install react and react-dom along with react-scripts
182191
// or template is presetend (via --internal-testing-template)
183-
if (!isReactInstalled(appPackage) || template) {
192+
if (!isReactInstalled(appPackage) || template || rerunYarn) {
184193
console.log(`Installing react and react-dom using ${command}...`);
185194
console.log();
186195

tasks/e2e-monorepos.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ popd
126126
pushd packages
127127
npx create-react-app newapp
128128
cd newapp
129-
yarn
130129
yarn build
131130
yarn start --smoke-test
132131
CI=true yarn test --watch=no
@@ -138,7 +137,6 @@ popd
138137
pushd packages
139138
npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/monorepos/cra-app cra-app2
140139
cd cra-app2
141-
yarn
142140
verifyBuild
143141
yarn start --smoke-test
144142
verifyTest

0 commit comments

Comments
 (0)