Skip to content

Spaces in project names are not handled properly #1649

Closed

Description

@wojtekmaj

Description

create-react-app allows you to create an app with spaces (and uppercase letters). Simply fire create-react-app "Example project" and it will be created! This, however, creates some issues stated below.

Expected behavior

  • create-react-app should disallow creating apps with spaces and uppercase letters

OR

  • create-react-app should detect if there are spaces/uppercase letters in project name provided by the user and:
    • Success message after creating an app should wrap project name in quotes if necessary
    • Project name in package.json should have spaces changed to dashes to avoid npm error

Actual behavior

After the app is created using the command above, a help message is displayed suggesting to go to the folder created by create-react app (sorry, don't remember it word-by word):

> App created successfully (...)
> Run the following command:
> cd **{project_name_here}**

Obviously, running command like cd ./My project won't work (we need to use command like cd "./My project").

Furthermore, running the app fails as the name containing spaces is also inserted into package.json file, and npm throws an error.

Activity

  1. added this to the 0.9.3 milestone on Feb 26, 2017
  2. Timer commented on Feb 26, 2017

    @Timer
    Contributor

    Nice catch! We would greatly appreciate if you could pull together a PR fixing this.
    I believe I like the section option more, automatically replacing spaces with dashes and lowercasing.

  3. gaearon commented on Feb 26, 2017

    @gaearon
    Contributor

    We should probably replace all unsafe characters and not just spaces.

  4. johann-sonntagbauer commented on Feb 27, 2017

    @johann-sonntagbauer
    Contributor

    Its kinda tricky to provide a generic escaping mechanism because the project name has some requirements to be met. Maybe a simple validation step based on https://github.com/npm/validate-npm-package-name during creation is sufficient enough.

  5. gaearon commented on Feb 28, 2017

    @gaearon
    Contributor

    Fixed by #1662.

  6. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions