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

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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 19

Most upvoted comments

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

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

The root of the problem appears to be with Yarn, and not React Static. Per https://github.com/yarnpkg/yarn/issues/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?

@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.

@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.

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?