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
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
Reproduce
Remove the global package
Check it is no longer available
Above should have no output
Add the global package
Check it is now available
Above should have output pointing to something like
/home/X/.local/bin/react-static
Try to create a project
Above fails with
error: react-static-create(1) does not exist, try --help
Check the command
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 problemTry using the command directly; so the command the symlink points to
The above works…
Workaround/Solution
Make the symlink absolute
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
@tannerlinsley postinstall hook? as it seems to be a problem with the
commander
packageThe 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
and then you can run the same command but with
greadlink
in place ofreadlink
.@luskin a useable (sic) workaround is to make the symlink absolute
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 thels -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 locatereact-static-create
in~/.config/yarn/global/node_modules/.bin/
So it seems to me thatcommander
(inexecuteSubCommand
) 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?