Skip to content
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

CLI Error: react-static-create(1) does not exist #807

Closed
f2net opened this issue Oct 9, 2018 · 19 comments
Closed

CLI Error: react-static-create(1) does not exist #807

f2net opened this issue Oct 9, 2018 · 19 comments

Comments

@f2net
Copy link

f2net commented Oct 9, 2018

Describe the bug
The CLI command

react-static create

shows an error.

To Reproduce
I just installed react-static globally using

yarn global add react-static (latest version of yarn 1.10.1)

If I launch

react-static create

I receive the error
error: react-static-create(1) does not exist, try --help

The help command is the only which works.

I'm using Node 10.9.0 on a Mac with MacOS Sierra 10.12.6.

I fear it's a problem with my environment, but other CLIs like create-react-app, gatsby or next work well.

Thank you,
Matteo

@f2net
Copy link
Author

f2net commented Oct 9, 2018

If I uninstall the global package with yarn and reinstall it with npm it's worst, because I see the package installed doing a

npm ls -g --depth 0

but if I run

react-static

it doesn't find the command.

@f2net
Copy link
Author

f2net commented Oct 9, 2018

I tried cleaning the yarn cache and reinstalling, but I receive the same error as before:

error: react-static-create(1) does not exist, try --help

@Pixelatex
Copy link
Collaborator

This sounds a lot like:

#789

@f2net
Copy link
Author

f2net commented Oct 9, 2018

Yes, thank you for pointing me.
Unfortunately for me npm (tried with 6.2.0 and 6.4.1) gives a worst result than yarn:

-bash: /usr/local/bin/react-static: No such file or directory

@f2net
Copy link
Author

f2net commented Oct 9, 2018

Ok, I confirm that it is a problem with yarn 1.10.x and also npm...
I uninstalled the react-static from npm, downgraded yarn to 1.9.4, installed from yarn and now it executes.

@Pixelatex
Copy link
Collaborator

I'll see if I can replicate the issue so we can know if it is caused by yarn/npm or some weird issue in our setup.

@Pixelatex
Copy link
Collaborator

Am unable to reconfirm this bug with npm or yarn so far... I'll try on my work computer tomorrow but I'm afraid it seems to env-specific.

@enscripter
Copy link

I had the issue but seemed to be related to where bin was pointing with yarn global bin and npm being in different areas I was also using nvm to make matters even more confusing running where react-static and where npm helped me figure out things were pointing in all different directions.

@Pixelatex
Copy link
Collaborator

Couldn't reproduce this on a new computer without pre-existing npm/yarn installs. :/

@f2net
Copy link
Author

f2net commented Oct 11, 2018

Thank you, so I think it's a problem with my environment.
I keep yarn 1.9.4 until I have time to understand what is the problem with my env.

@stefanprobst
Copy link

I have the exact same problem. I have react-static in ~/.yarn/bin/ which is a symlink to ~/.config/yarn/global/node_modules/.bin/react-static which again is a symlink to ~/.config/yarn/global/node_modules/react-static/bin/react-static.

commander tries to locate react-static-create in ~/.config/yarn/global/node_modules/.bin/
So it seems to me that commander (in executeSubCommand) fails to properly resolve all symlinks?

This is not a problem with yarn 1.9 because it directly links from .yarn/bin/ to .config/yarn/global/node_modules/react-static/bin/.

Not sure who's to blame here?

@AubreyHewes
Copy link

AubreyHewes commented Nov 13, 2018

I have the same problem.. I also have found a workaround/resolution

It seems that it is indeed due to the installed symlink pointing to a relative path that is breaking as commander does not follow. If you execute the command directly it works... see workaround/solution below.

Environment

$ lsb_release -ds && uname -rv && node -v && yarn -v && react-static -V
Ubuntu 17.10
4.13.0-46-generic #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018
v8.12.0
1.12.3
5.9.12

Reproduce

Remove the global package
yarn global remove react-static
Check it is no longer available
which react-static

Above should have no output

Add the global package
yarn global add react-static
Check it is now available
which react-static

Above should have output pointing to something like /home/X/.local/bin/react-static

Try to create a project
react-static create

Above fails with
error: react-static-create(1) does not exist, try --help

Check the command
ls -lad $(which react-static)

Above outputs something like
/home/X/.local/bin/react-static -> ../../.config/yarn/global/node_modules/.bin/react-static

Note the ../../ in the symlink; it seems this is the problem

Try using the command directly; so the command the symlink points to
$(readlink -f $(which react-static)) create

The above works..

? What should we name this project? my-static-site

Workaround/Solution

Make the symlink absolute

ln -fs $(readlink -f $(which react-static)) $(which react-static)
ls -lad $(which react-static)

Outputs:
/home/X/.local/bin/react-static -> /home/X/.config/yarn/global/node_modules/react-static/bin/react-static

The symlink is now absolute and the command works ;-)

react-static create

? What should we name this project? my-static-site

@tannerlinsley postinstall hook? as it seems to be a problem with the commander package

@luskin
Copy link

luskin commented Nov 21, 2018

I'm having this issue as well, trying to switch from Gatsby to React-Static but can't even get a basic project off the ground. Anybody find a solution to this bug?

@AubreyHewes
Copy link

@luskin a useable (sic) workaround is to make the symlink absolute

ln -fs $(readlink -f $(which react-static)) $(which react-static)

Above works on linux based systems. osx, afaik, does not support readlink -f (out of the box) so in this case you would have to manually fix the ls -lad $(which react-static) symlink to the absolute path of the linked item.

Let me know if you get it working using this...

Note: on an update of react-static this would have to be repeated.

@MartinRosenberg
Copy link

@luskin And to make @AubreyHewes' workaround work on macOS, you have to first run

brew install coreutils

and then you can run the same command but with greadlink in place of readlink.

@dan-dr
Copy link

dan-dr commented Nov 24, 2018

yeah why is this closed... still happening. thanks for the workaround @luskin

@Pixelatex
Copy link
Collaborator

This is not 100% reproducible and might be caused by your local setup.

@Pixelatex
Copy link
Collaborator

I tried to reproduce this on 4 separate devices. 2 of them who never had react-static on it. Tried it with both yarn & npm as well...

@MartinRosenberg
Copy link

The root of the problem appears to be with Yarn, and not React Static. Per yarnpkg/yarn#648 (as mentioned in #789), Yarn has longstanding issues with global packages, such as installing to undesirable locations (particularly with nvm) and not linking. Reinstalling react-static with npm fixes the issue, or you can make the necessary adjustments for Yarn.

@Pixelatex, would you be willing to get fixes in for the Quick Start docs with a warning about using yarn global add, and/or instructions for resolving the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants