Yarn version 2 and higher fails to execute happo-ci scripts
Closed this issue · 1 comments
trotzig commented
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 callbash 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 thehappo-ci-github-actions
script directly. Failed similarly.
trotzig commented
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