Skip to content

Commit 00652d5

Browse files
committed
Use npm as package manager by default
This removes the --use-npm flag and adds the --use-yarn flag. It also removes the previous behavior of checking for the existence of yarn as the signal to use it as the package manager.
1 parent b3a60ab commit 00652d5

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

packages/create-react-app/createReactApp.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function init() {
6969
'--template <path-to-template>',
7070
'specify a template for the created project'
7171
)
72-
.option('--use-npm')
72+
.option('--use-yarn')
7373
.option('--use-pnp')
7474
.allowUnknownOption()
7575
.on('--help', () => {
@@ -228,14 +228,14 @@ function init() {
228228
program.verbose,
229229
program.scriptsVersion,
230230
program.template,
231-
program.useNpm,
231+
program.useYarn,
232232
program.usePnp
233233
);
234234
}
235235
});
236236
}
237237

238-
function createApp(name, verbose, version, template, useNpm, usePnp) {
238+
function createApp(name, verbose, version, template, useYarn, usePnp) {
239239
const unsupportedNodeVersion = !semver.satisfies(
240240
// Coerce strings with metadata (i.e. `15.0.0-nightly`).
241241
semver.coerce(process.version),
@@ -276,7 +276,6 @@ function createApp(name, verbose, version, template, useNpm, usePnp) {
276276
JSON.stringify(packageJson, null, 2) + os.EOL
277277
);
278278

279-
const useYarn = useNpm ? false : shouldUseYarn();
280279
const originalDirectory = process.cwd();
281280
process.chdir(root);
282281
if (!useYarn && !checkThatNpmCanReadCwd()) {
@@ -351,15 +350,6 @@ function createApp(name, verbose, version, template, useNpm, usePnp) {
351350
);
352351
}
353352

354-
function shouldUseYarn() {
355-
try {
356-
execSync('yarnpkg --version', { stdio: 'ignore' });
357-
return true;
358-
} catch (e) {
359-
return false;
360-
}
361-
}
362-
363353
function install(root, useYarn, usePnp, dependencies, verbose, isOnline) {
364354
return new Promise((resolve, reject) => {
365355
let command;

tasks/e2e-installs.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ cd "$temp_app_path"
112112
npx create-react-app test-app-dist-tag --scripts-version=@latest
113113
cd test-app-dist-tag
114114

115-
# Check corresponding scripts version is installed and no TypeScript is present.
115+
# Check corresponding scripts version is installed and no TypeScript or yarn is present by default
116116
exists node_modules/react-scripts
117117
! exists node_modules/typescript
118118
! exists src/index.tsx
119+
! exists yarn.lock
119120
exists src/index.js
120121
checkDependencies
121122

@@ -133,16 +134,16 @@ grep '"version": "1.0.17"' node_modules/react-scripts/package.json
133134
checkDependencies
134135

135136
# ******************************************************************************
136-
# Test --use-npm flag
137+
# Test --use-yarn flag
137138
# ******************************************************************************
138139

139140
cd "$temp_app_path"
140-
npx create-react-app test-use-npm-flag --use-npm --scripts-version=1.0.17
141-
cd test-use-npm-flag
141+
npx create-react-app test-use-yarn-flag --use-yarn --scripts-version=1.0.17
142+
cd test-use-yarn-flag
142143

143144
# Check corresponding scripts version is installed.
144145
exists node_modules/react-scripts
145-
[ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist"
146+
exists yarn.lock
146147
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
147148
checkDependencies
148149

@@ -277,7 +278,7 @@ npm start --smoke-test
277278
# Test when PnP is enabled
278279
# ******************************************************************************
279280
cd "$temp_app_path"
280-
npx create-react-app test-app-pnp --use-pnp
281+
npx create-react-app test-app-pnp --use-yarn --use-pnp
281282
cd test-app-pnp
282283
! exists node_modules
283284
exists .pnp.js

0 commit comments

Comments
 (0)