Skip to content

Bug Fixed: Create react app won't work on Windows if there are spaces… #12780

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

Closed
wants to merge 1 commit into from
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
13 changes: 13 additions & 0 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ function createApp(name, verbose, version, template, useYarn, usePnp) {
const root = path.resolve(name);
const appName = path.basename(root);

// We check if (the user is on windows and the project path contains a space)
if (isWindows() && stringContainsSpace(root)) {
console.error('Project path cannot contain spaces on Windows.');
process.exit(1);
}

checkAppName(appName);
fs.ensureDirSync(name);
if (!isSafeToCreateProjectIn(root, name)) {
Expand Down Expand Up @@ -1116,6 +1122,13 @@ function checkForLatestVersion() {
});
});
}
function isWindows() {
// https://nodejs.org/api/process.html#processplatform
return process.platform === 'win32';
}
function stringContainsSpace(string) {
return string.indexOf(' ') >= 0;
}

module.exports = {
init,
Expand Down