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

Yarn version 2 and higher fails to execute happo-ci scripts #270

Closed
trotzig opened this issue Mar 28, 2024 · 1 comment
Closed

Yarn version 2 and higher fails to execute happo-ci scripts #270

trotzig opened this issue Mar 28, 2024 · 1 comment

Comments

@trotzig
Copy link
Contributor

trotzig commented Mar 28, 2024

While upgrading to Yarn 4 (from v1.22) I noticed that invoking yarn happo-ci-github-actions would fail with this error:

node_modules/happo.io/bin/happo-ci-github-actions:3
# Make the whole script fail on errors
^
SyntaxError: Invalid or unexpected token

I believe this is because Yarn treats any script as a node javascript file starting from v2. I played around with several workarounds in a PR but eventually gave up. I tried these things:

  • Wrap happo-ci-github-actions in a script where I explicitly call bash node_modules/.bin/happo-ci-github-actions. It got past the first error but when a sub script was called I ended up with the same issue just further down the flow of execution.
  • Stop using yarn altogether and call the happo-ci-github-actions script directly. Failed similarly.
@trotzig
Copy link
Contributor Author

trotzig commented Mar 28, 2024

I found the best workaround to be to use npx -p happo.io in place of yarn. So turning this

yarn happo-ci-github-actions

to

npx -p happo.io happo-ci-github-actions

To prevent npx from downloading another copy of the happo.io library (which it would do since yarn doesn't store dependencies in the same place as before), I added the following to .yarnrc.yml:

nodeLinker: node-modules

Here's a link to a pull-request where you can look at the changes made:
happo/happo-plugin-storybook#116

@trotzig trotzig closed this as completed Mar 28, 2024
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

1 participant