Skip to content

typo in '--help': index -> create-react-app #1796

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
funderburkjim opened this issue Mar 11, 2017 · 8 comments
Closed

typo in '--help': index -> create-react-app #1796

funderburkjim opened this issue Mar 11, 2017 · 8 comments

Comments

@funderburkjim
Copy link

I am a beginning to learn react.
After installing create-react-app, I issued the (empty) command

$ create-react-app
Please specify the project directory:
  index <project-directory>

For example:
  index my-react-app

Run index --help to see all options.

As you see, the word 'index' appears where the word 'create-react-app' should appear.

Similar typo in 'create-react-app --help'.

This small typo is confusing to the beginner.

@gaearon
Copy link
Contributor

gaearon commented Mar 11, 2017

Oops. Not sure when we broke this.
Node / npm / OS versions?

@funderburkjim
Copy link
Author

I'm using Windows 10.

I downloaded the node (and npm) from the latest stable release as of today, from the nodejs site.

@funderburkjim
Copy link
Author

I don't know if it is relevant, but I am also using Git Bash.

@gaearon
Copy link
Contributor

gaearon commented Mar 11, 2017

I downloaded the node (and npm) from the latest stable release as of today, from the nodejs site.

Still, this would help:

node -v
npm -v

There is a good reason these commands are in the issue template. 😉

@mwq27
Copy link

mwq27 commented Mar 12, 2017

I have node v6.2.1, npm v3.10.8 on OSX v10.11.6 and create-react-app@1.3.0, and I see this output:

~/P ❯❯❯ create-react-app 
Please specify the project directory:
  create-react-app <project-directory>

For example:
  create-react-app my-react-app

Run create-react-app --help to see all options.

@mkazantsev
Copy link
Contributor

Can easily reproduce this on Windows 10 in Git Bash, as @funderburkjim points out, with latest stable Node and NPM (Node v6.10.0, NPM v.3.10.10).

I think the issue is in what program.name() returns (see commander).

The difference between OSs here is that on OS X which create-react-app returns something like ~/.nvm/versions/node/v6.10.0/bin/create-react-app, which is in turn a JS file. On Windows, it returns ~/AppData/Roaming/npm/create-react-app, which is a bash script of the following content:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/create-react-app/index.js" "$@"
  ret=$?
else
  node  "$basedir/node_modules/create-react-app/index.js" "$@"
  ret=$?
fi
exit $ret

Long story short, it explicitly calls node index.js, hence the index in program.name(). The script, I assume, is generated by NPM when installing the package globally.

I might be missing a lot of context being a complete newbie here, but it looks like right now a canonical way to use create-react-app is to run it as a global command and alternatives are less well-supported. Do we actually want that usage and help messaging to say something other than create-react-app depending on environment? I appreciate hard coding it is suboptimal, but right now I don't see much more elegant solution to solve this for Windows.

@Timer
Copy link
Contributor

Timer commented Mar 20, 2017

Looks like we can explicity pass a name by changing https://github.com/facebookincubator/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L26 from commander to new commander.Command(name).
We can fetch the name from package.json or similar.

@mkazantsev
Copy link
Contributor

mkazantsev commented Mar 20, 2017

Good idea, thank you @Timer. Created a PR with a change that does exactly that. Please let me know what you think.

@Timer Timer closed this as completed Jun 29, 2017
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

5 participants