Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ const program = new commander.Command(packageJson.name)
)}`
);
console.log();

if (isPackageInstalledGlobally('create-react-app')) {
console.log(
` [Please make sure you are using npx] ${chalk.yellow(
'global installation for create-react-app is deprecated.'
)}`
);
}
})
.parse(process.argv);

Expand Down Expand Up @@ -330,6 +338,18 @@ function createApp(
);
}

function isPackageInstalledGlobally(packageName) {
try {
const pathToGlobalPackages = execSync('npm root -g');
const packages = execSync(`ls ${pathToGlobalPackages}`)
.toString()
.split('\n');
return packages.includes(packageName);
} catch (e) {
return false;
}
}

function shouldUseYarn() {
try {
execSync('yarnpkg --version', { stdio: 'ignore' });
Expand Down